[source lang ="cpp"]#include <windows.h>
#include "resource.h"
const char szAppName[] = "Splitter";
HINSTANCE hInstance;
HWND hwnd, hwndChild1, hwndChild2, hwndChild3;
#define ID_CHILD1 50010
SizeWindowContents(int nWidth, int nHeight)
{
//We will get SetScrollInfo's called by the listview, because
//it has been changed in size
MoveWindow(hwndChild1, 0, 200, 200, nHeight, TRUE);
MoveWindow(hwndChild2, 206, 0, nWidth , nHeight, TRUE);
}
BOOL CALLBACK ObjectDlgProc(HWND hWndTool, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
return TRUE;
}
return FALSE;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
hwndChild1 = CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT", "",
WS_CHILD | WS_VISIBLE
| WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
200,CW_USEDEFAULT,200,CW_USEDEFAULT,hwnd, (HMENU)ID_CHILD1, hInstance, NULL);
hwndChild2 = CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT", "",
WS_VISIBLE|WS_CHILD,
0,0,0,0,hwnd, 0, hInstance, NULL);
hwndChild3 = CreateDialog(hInstance, MAKEINTRESOURCE (IDD_TEST), hwnd, (DLGPROC)ObjectDlgProc);
ShowWindow(hwndChild3, SW_SHOW);
return 0;
case WM_SIZE:
{
HWND hwndChild1;
RECT rcChild1;
GetClientRect(hwnd, &rcChild1);
hwndChild1 = GetDlgItem(hwnd, ID_CHILD1);
SetWindowPos(hwndChild1, NULL, 0, 200, rcChild1.left, 200 - rcChild1.bottom, SWP_NOZORDER);
SizeWindowContents(LOWORD(lParam), HIWORD(lParam));
}
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wc;
MSG msg;
//
// Register our main window class
//
wc.cbSize = sizeof(wc);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);;
wc.lpszMenuName = 0;
wc.lpszClassName = szAppName;
wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
RegisterClassEx(&wc);
hInstance = hInst;
//
// Create the main window. This window
// will host two child controls.
//
hwnd = CreateWindowEx(0, // extended style (not needed)
szAppName, // window class name
szAppName, // window caption
WS_OVERLAPPEDWINDOW|
WS_CLIPCHILDREN, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
800, // initial x size
600, // initial y size
NULL, // parent window handle
NULL, // use window class menu
hInst, // program instance handle
NULL); // creation parameters
ShowWindow(hwnd, nShowCmd);
while(GetMessage(&msg, NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
[Edited by - Aviscowboy1 on March 30, 2006 1:31:55 PM]