is there a way to split a singal window to two windows with two handles?
what i mean is: to the user it will look like a singal window, but it will enable me to split the big window into areas, where each area has it's own handle (HWND).
thank you,
This is a discussion on one window, two handles within the Windows Programming forums, part of the Platform Specific Boards category; is there a way to split a singal window to two windows with two handles? what i mean is: to ...
is there a way to split a singal window to two windows with two handles?
what i mean is: to the user it will look like a singal window, but it will enable me to split the big window into areas, where each area has it's own handle (HWND).
thank you,
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
no, but you can create a bunch of HRGN's and select them into the window's device context as needed.
Code:int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000 <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000 )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 0;}
regions would be an interesting approach, depends on what he's trying to do. It seems to me that it would be better to make two windows to start with. Perhaps docked on a parent window. You can set the parent on the fly to undock it. You can always create new windows and move the stuff over.
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
FillYourBrain, I don't really understand what you mean?
can you give me an example please?
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
You could use child windows that would appear to be one continuous window yet contained different handles. This approach would probably resolve what you are trying to do. I am going to post a basic app below that uses 2 child windows that change colors when you click on them. Take note that it appears as if it is one window when the colors match. Additionally their size depends on the main window size, ensuring the illusion.
Hope this helps. Happy Coding!!Code:#include <windows.h> #define numChild 2 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); //children window procedure LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM); TCHAR szChildClass [] = TEXT("Children"); //Child class name int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT("ChildWindowDemo"); WNDCLASS wc; MSG msg; HWND hwnd; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = szAppName; wc.lpszMenuName = NULL; wc.style = CS_HREDRAW | CS_VREDRAW; if(!RegisterClass(&wc)) { MessageBox(NULL, TEXT("Could not register class"), szAppName, MB_ICONERROR); return 0; } //define and register child window class wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpfnWndProc = ChildWndProc; wc.hIcon = NULL; wc.lpszClassName = szChildClass; RegisterClass(&wc); //------------------------------------- hwnd = CreateWindow(szAppName, TEXT("Child Window Demo"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, iCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndChild[numChild]; //create array to hold children int cxBlock, cyBlock, x; switch(message) { case WM_CREATE: //create our children for(x = 0; x < numChild; x++) { hwndChild[x] = CreateWindow(szChildClass, NULL, WS_CHILDWINDOW | WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)(1 << 8 | x), //child window ID (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL); } return 0; case WM_SIZE: //each window will be 1/2 width of parent and = height cxBlock = LOWORD(lParam) / numChild; cyBlock = HIWORD(lParam); for(x = 0; x < numChild; x++) { MoveWindow(hwndChild[x], x * cxBlock, 0, cxBlock, cyBlock, TRUE); } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); } LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int iColor; int bkgColor[4] = {WHITE_BRUSH, LTGRAY_BRUSH, DKGRAY_BRUSH, BLACK_BRUSH}; switch(message) { case WM_CREATE: iColor = 0; SetWindowLong(hwnd, 0, 0); return 0; case WM_LBUTTONUP: SetClassLong(hwnd, GCL_HBRBACKGROUND, (LONG)GetStockObject(bkgColor[iColor])); InvalidateRect(hwnd, NULL, TRUE); if(!(iColor == 3)) { iColor++; }else { iColor = 0; } return 0; } return DefWindowProc(hwnd, message, wParam, lParam); }
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
I use a program for my job that is made up of four separate sections. Separating the four sections is a bar that the mouse allows you to resize the four different sections (either horizontally or vertically depending on how that bar stretches across the screen). I was wondering how this was done. The way this program is designed, it seems like the controls are children of the main program. But the controls change location on the screen based on how you resize the different sections.
Is this done using four separate windows (like the example above) or is this done using something like Windows Regions?
Thanks
Tyouk
Those resizeable bars are just another type of control used in Windows Forms. I forget what they're called - but they're predefined in the API (I don't recall seeing them in Win32, but at least as early VS.NET they've been there - most likely much earlier.
I think the control called a splitter:
http://www.catch22.net/tuts/splitter.asp
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
andyhunter, your code is exacly what i need, but i don't understand one small thing in your code...
there are two child windows in that main parent one, but only one ChildWndProc, did you mean that this will control both of the child windows?
if so, how can i gain more control over the two child windows?Code://define and register child window class wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpfnWndProc = ChildWndProc; wc.hIcon = NULL; wc.lpszClassName = szChildClass;
Last edited by Devil Panther; 01-15-2005 at 03:45 AM.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Yes, for the above example both child windows shared the same windows callback procedure. You could decide to register a class for each child window and create a seperate windows procedure for each if you wanted them to be seperate.
Another approach is to have the child window procedure send a message to the parent window procedure detailing a message and the child window ID. This way you could also have more control over individual windows.
Happy Coding!!!
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
thank you very much.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.