|
-
July 15th, 2010, 07:23 AM
#1
PropertySheet Embedding Problem
Hi all!
I am facing a problem when embedding a propertysheet in my main dialog box. I have use the CreateWindow() function to create my main dialog box and two PUSHBUTTONS, which work just fine but when I include the propertysheet as a child on top of the dialog box the buttons do not work.
I believe it has something to do with the handles but no luck yet. If there are any suggestions on what I should check, it would be greatly appreciated!
Ludvig
P.S. I have not included any code, but if anyone wants to check it, I will be more than happy to provide it!
-
July 15th, 2010, 08:00 AM
#2
Re: PropertySheet Embedding Problem
What do you mean by propertysheet? This isn't a standard window. There is CPropertySheet in MFC but that is derived from CDialog and is a popup window and would be difficult at best to embed into another dialog as a child window. For a property-sheet like effect, use a tab control.
-
July 15th, 2010, 08:01 AM
#3
Re: PropertySheet Embedding Problem
 Originally Posted by ludvig.peers
P.S. I have not included any code, but if anyone wants to check it, I will be more than happy to provide it!
Should be useful. Otherwise we can only guess.
-
July 15th, 2010, 08:15 AM
#4
Re: PropertySheet Embedding Problem
@to hoxsiew:
- CPropertySheet isn't derived from CDialog but from CWnd.
- CPropertySheet wraps a Windows Property Sheet, let's say it "standard window". See: Property Sheet in MSDN.
- Can be child with no problem in any other parent window.
Last edited by ovidiucucu; July 15th, 2010 at 08:19 AM.
-
July 15th, 2010, 08:19 AM
#5
Re: PropertySheet Embedding Problem
I am using the propertysheet sutructures in WIN API.
About Property Sheets
I have created the dialog box and the two buttons in InitInstance
Code:
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
g_hInst = hInstance; // Store instance handle in our global variable
//Handle to main dialog box
g_hwndMain = CreateWindowEx(NULL, g_szWindowClass, g_szTitle, WS_OVERLAPPED | WS_SYSMENU,
GetSystemMetrics(SM_CXSCREEN)/2-253, GetSystemMetrics(SM_CYSCREEN)/2-205, 506, 410, NULL, NULL, hInstance, NULL); //change size
//Handle to Send Button
g_hwndSendButton = CreateWindow(
"BUTTON", /* this makes a "button" */
"SEND", /* this is the text which will appear in the button */
BS_PUSHBUTTON |WS_VISIBLE | WS_CHILD ,
409, /* these four lines are the position and dimensions of the button */
310,
85,
26,
g_hwndMain, /* this is the buttons parent window */
(HMENU)IDC_SEND, /* these next two lines tell windows what to do when the button is pressed */
g_hInst,
NULL);
//Handle to Read Button
g_hwndReadButton = CreateWindow(
"BUTTON",
"READ",
BS_PUSHBUTTON |WS_VISIBLE | WS_CHILD,
320,
310,
85,
26,
g_hwndMain,
(HMENU)IDC_READ,
g_hInst,
NULL);
if (!g_hwndMain)
{
return FALSE;
}
g_hwndPropSheet = CreatePropSheet();
if(-1 == (int)g_hwndPropSheet)
{
return -1;
}
SetWindowLongPtr(g_hwndPropSheet, GWL_STYLE, WS_CHILD);
SetParent(g_hwndPropSheet, g_hwndMain);
SetWindowLongPtr(g_hwndPropSheet, GWL_EXSTYLE, WS_EX_CONTROLPARENT);
InitPPSheetSize();
ShowWindow(g_hwndMain, nCmdShow);
UpdateWindow(g_hwndMain);
return TRUE;
}
This is a modification on a code that I found here in codeguru:
http://www.codeguru.com/forum/showthread.php?t=323943
The function InitPPSheetSize(); that I call in InitInstance contains:
Code:
void InitPPSheetSize()
{
RECT rectWnd;
RECT rectButton;
GetWindowRect(g_hwndPropSheet, &rectWnd);
HWND hWnd = ::GetDlgItem(g_hwndPropSheet, IDOK);
if(!hWnd)
{
DebugBreak();
}
GetWindowRect(hWnd, &rectButton); //::
SetWindowPos(g_hwndPropSheet, NULL,30,10,
rectWnd.right - rectWnd.left, rectButton.top - rectWnd.top,
SWP_SHOWWINDOW);
for (int i = 0; i < _ArrCount(PropSheetButtons); i++)
{
hWnd = ::GetDlgItem(g_hwndPropSheet, PropSheetButtons[i]);
if (hWnd != NULL)
{
ShowWindow(hWnd, SW_HIDE); //::
EnableWindow(hWnd, FALSE); //::
}
}
}
I wanted two general buttons 'send' and 'read' for the three tabs that I have in my propertysheet, so I thought I would include them as childs in my main dialog box. Should I just use the default buttons 'OK' and 'Cancel' that are provided by the propertysheet() function and just rename them accordingly? Any ideas would be more than welcome!
Ludvig
P.S. I apologize but I am a bit new to C++ and WIN API.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|