2 * Copyright (c) 2004 Massachusetts Institute of Technology
\r
4 * Permission is hereby granted, free of charge, to any person
\r
5 * obtaining a copy of this software and associated documentation
\r
6 * files (the "Software"), to deal in the Software without
\r
7 * restriction, including without limitation the rights to use, copy,
\r
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
\r
9 * of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be
\r
13 * included in all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
27 #include<khuidefs.h>
\r
32 KHMEXP khm_int32 KHMAPI khui_ps_create_sheet(khui_property_sheet ** sheet)
\r
34 khui_property_sheet * ps;
\r
36 ps = malloc(sizeof(*ps));
\r
37 ZeroMemory(ps, sizeof(*ps));
\r
39 ps->header.dwSize = sizeof(ps->header);
\r
40 ps->header.dwFlags = PSH_MODELESS | PSH_PROPTITLE;
\r
41 ps->status = KHUI_PS_STATUS_NONE;
\r
45 return KHM_ERROR_SUCCESS;
\r
48 KHMEXP khm_int32 KHMAPI khui_ps_add_page(
\r
49 khui_property_sheet * sheet,
\r
52 LPPROPSHEETPAGE ppage,
\r
53 khui_property_page ** page)
\r
55 khui_property_page * p;
\r
57 p = malloc(sizeof(*p));
\r
58 ZeroMemory(p, sizeof(*p));
\r
60 p->credtype = credtype;
\r
61 p->ordinal = ordinal;
\r
70 return KHM_ERROR_SUCCESS;
\r
73 KHMEXP khm_int32 KHMAPI khui_ps_find_page(
\r
74 khui_property_sheet * sheet,
\r
76 khui_property_page ** page)
\r
78 khui_property_page * p;
\r
83 if(p->credtype == credtype)
\r
90 return KHM_ERROR_SUCCESS;
\r
93 return KHM_ERROR_NOT_FOUND;
\r
97 int __cdecl ps_order_func(const void *l, const void * r) {
\r
102 KHMEXP HWND KHMAPI khui_ps_show_sheet(HWND parent, khui_property_sheet * s)
\r
104 khui_property_page * p;
\r
105 HPROPSHEETPAGE phpsp[KHUI_PS_MAX_PSP];
\r
106 khui_property_page * ppgs[KHUI_PS_MAX_PSP];
\r
111 s->header.hwndParent = parent;
\r
112 s->header.nPages = s->n_pages;
\r
117 p->h_page = CreatePropertySheetPage(p->p_page);
\r
122 phpsp[i++] = p->h_page;
\r
126 /*TODO: sort property sheets */
\r
128 s->header.phpage = phpsp;
\r
130 prv = PropertySheet(&s->header);
\r
135 /*TODO: better handling for this */
\r
140 dw = GetLastError();
\r
141 s->status = KHUI_PS_STATUS_RUNNING;
\r
145 s->hwnd_page = PropSheet_GetCurrentPageHwnd(hw);
\r
151 KHMEXP LRESULT KHMAPI khui_ps_check_message(
\r
152 khui_property_sheet * sheet,
\r
157 if(sheet->hwnd == NULL)
\r
160 lr = PropSheet_IsDialogMessage(sheet->hwnd, pmsg);
\r
162 sheet->hwnd_page = PropSheet_GetCurrentPageHwnd(sheet->hwnd);
\r
163 if(sheet->hwnd_page == NULL &&
\r
164 sheet->status == KHUI_PS_STATUS_RUNNING)
\r
166 sheet->status = KHUI_PS_STATUS_DONE;
\r
172 KHMEXP khm_int32 KHMAPI khui_ps_destroy_sheet(khui_property_sheet * sheet)
\r
174 khui_property_page * p;
\r
176 DestroyWindow(sheet->hwnd);
\r
177 sheet->hwnd = NULL;
\r
187 return KHM_ERROR_SUCCESS;
\r