How do I embed a dialog-like recource into the main window of a windows app (not just a dialog app). I have seen it some where but I don't know how he did it.
Thanks
Chris
How do I embed a dialog-like recource into the main window of a windows app (not just a dialog app). I have seen it some where but I don't know how he did it.
Thanks
Chris
When you say dialog based resource do you mean a single ctrl OR a whole dialog you made in the resource editor?
For a single ctrl use CreateWindow(), sepecify the HMENU as the ID (#define one) and its msg's will be sent to the callback of the parent HWND param.
For a dialog, create it and use SetWindowPos() hiding it when not needed. Create it with out the system menu and I would make it a child of the main depending on if it needs a seperate callback.
Is that what you want?
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
also, make sure the dialog is modeless!!!
Quidquid latine dictum sit, altum sonatur.
Whatever is said in Latin sounds profound.
That sounds like the right thing for me, so I searched for SetWindowPos() in the msdn library, but it came up with nothing... Could you please explain it to me?
i just tried again without the '()' and I found it. I'm reading it now and if I have any problems with, i'll post another reply to this thread...
SetWindowPos() doesn't actually have a parameter for the ID of the recource, so how will it know what to place at the specified co-ordinates?
The first param is the HWND of the dialog you want to move
Say we have a main window (MainHwnd is its HWND)
On it a frame ctrl or similar has been placed called IDC_FRAME. Or divide up the area as you need.
Our dialog to place in the frame has DIALOGhWnd returned when we created it.
Should check to see if fits eg iWidthDlg<FRAME_Rect.right-FRAME_Rect.left;Code://find the WHOLE dimensions of the dialog to move GetWindowRect(DIALOGhWnd,&DLG_Rect); iWidthDlg=DLG_Rect.right-DLG_Rect.left; iHeightDlg=DLG_Rect.bottom-DLG_Rect.top; //find where to put it in the frame FRAMEhWnd=GetDlgItem(hMainWnd,IDC_FRAME); GetClientRect(FRAMEhWnd,&FRAME_Rect); //place at top left corner of frame SetWindowPos(DIALOGhWnd, HWND_TOPMOST, FRAME_Rect.left, FRAME_Rect.top, iWidthDlg, iHeightDlg, 0);
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
How do initially do this?Originally posted by novacain
On it a frame ctrl or similar has been placed called IDC_FRAME. Or divide up the area as you need.
HWND hDlg;//handle to dialog
HWND hFrame;//handle to frame ctrl
#define IDC_FRAME 10001//set up resource ID#
int iMargin=10;//extra distance from edge of main window (for appearance)
Now you have to stop it being moved, but that is another story.Code:GetWindowRect(hDlg,&DlgRect);//sometimes client rect works better //create an invisible frame for the dlg hFrame=CreateWindow("Static",NULL,WS_CHILD, DlgRect.left+iMargin,DlgRect.top+iMargin, DlgRect.right-DlgRect.left+iMargin ,DlgRect.bottom-DlgRect.top+iMargin, hwnd,(HMENU)IDC_FRAME,hInst,NULL); //set the dlg to the frame and make sure it is on the top and visible SetWindowPos(hDlg,HWND_TOPMOST, DlgRect.left+iMargin,DlgRect.top+iMargin, DlgRect.right-DlgRect.left+iMargin ,DlgRect.bottom-DlgRect.top+iMargin, SWP_SHOWWINDOW|SWP_DRAWFRAME);
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill