19. februar 2009 - 17:39
#1
#include <windows.h>
//Program Side 1
#define IDC_STATIC_1 1201
#define IDC_OVER_1 1202
#define IDC_TEXT_1 1203
#define IDC_BUTTON1_1 1204
#define IDC_BUTTON2_1 1205
//Program Side 2
#define IDC_STATIC_2 1206
#define IDC_OVER_2 1207
#define IDC_TEXT_2 1208
#define IDC_BUTTON1_2 1209
#define IDC_BUTTON2_2 1210
HINSTANCE InstanceHandle;
LRESULT CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
//Program Side 1
{
CreateWindow("STATIC",
"0", // Initial Text
WS_CHILD | SS_BITMAP | WS_VISIBLE, // Style
0, 0, 100, 100, // position
hwndDlg, // Owner
(HMENU)(IDC_STATIC_1), // ID
InstanceHandle, // The application
0);
HBITMAP Bitmap = (HBITMAP )LoadImage(0, "Head_img.bmp", IMAGE_BITMAP, 494, 150, LR_LOADFROMFILE);
if(!Bitmap)
MessageBox(hwndDlg, "No Image 1", "---", 0);
SendDlgItemMessage(hwndDlg, IDC_STATIC_1, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM )Bitmap);
}
{
CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"overskrift", // Initial Text
WS_CHILD | WS_VISIBLE | ES_NUMBER | ES_READONLY, // Style
10, 160, 475, 40, // position
hwndDlg, // Owner
(HMENU)(IDC_OVER_1), // ID
InstanceHandle, // The application
0);
}
{
CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"Text-Box", // Initial Text
WS_CHILD | WS_VISIBLE | ES_NUMBER | ES_READONLY, // Style
10, 210, 475, 300, // position
hwndDlg, // Owner
(HMENU)(IDC_TEXT_1), // ID
InstanceHandle, // The application
0);
}
{
CreateWindow("BUTTON",
"Afslut", // Button Text
WS_CHILD | WS_VISIBLE | WS_TABSTOP, // Style
10, 525, 120, 30, // position
hwndDlg, // Owner
(HMENU)(IDC_BUTTON1_1), // ID
InstanceHandle, // The application
0);
}
{
CreateWindow("BUTTON",
"Acepter", // Button Text
WS_CHILD | WS_VISIBLE | WS_TABSTOP, // Style
364, 525, 120, 30, // position
hwndDlg, // Owner
(HMENU)(IDC_BUTTON2_1), // ID
InstanceHandle, // The application
0);
}
//Program Side 2
{
CreateWindow("STATIC",
"0", // Initial Text
WS_CHILD | WS_DISABLED | SS_BITMAP , // Style
0, 0, 100, 100, // position
hwndDlg, // Owner
(HMENU)(IDC_STATIC_2), // ID
InstanceHandle, // The application
0);
HBITMAP Bitmap = (HBITMAP )LoadImage(0, "Head_img.bmp", IMAGE_BITMAP, 494, 150, LR_LOADFROMFILE);
if(!Bitmap)
MessageBox(hwndDlg, "No Image 2", "---", 0);
SendDlgItemMessage(hwndDlg, IDC_STATIC_2, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM )Bitmap);
}
{
CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"overskrift 2", // Initial Text
WS_CHILD | WS_DISABLED | ES_NUMBER | ES_READONLY, // Style
10, 160, 475, 40, // position
hwndDlg, // Owner
(HMENU)(IDC_OVER_2), // ID
InstanceHandle, // The application
0);
}
{
CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"Text-Box 2", // Initial Text
WS_CHILD | WS_DISABLED | ES_NUMBER | ES_READONLY, // Style
10, 210, 475, 300, // position
hwndDlg, // Owner
(HMENU)(IDC_TEXT_2), // ID
InstanceHandle, // The application
0);
}
{
CreateWindow("BUTTON",
"Afslut", // Button Text
WS_CHILD | WS_DISABLED | WS_TABSTOP, // Style
10, 525, 120, 30, // position
hwndDlg, // Owner
(HMENU)(IDC_BUTTON1_2), // ID
InstanceHandle, // The application
0);
}
{
CreateWindow("BUTTON",
"Send", // Button Text
WS_CHILD | WS_DISABLED | WS_TABSTOP, // Style
364, 525, 120, 30, // position
hwndDlg, // Owner
(HMENU)(IDC_BUTTON2_2), // ID
InstanceHandle, // The application
0);
}
break;
case WM_KEYDOWN:
if(wParam == VK_F4)
{
PostQuitMessage(0);
}
break;
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON1_1)
{
DestroyWindow(hwndDlg);
}
if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON2_1)
{
SetWindowLong(GetDlgItem(hwndDlg, IDC_STATIC_1), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_STATIC_1), GWL_STYLE) & ~WS_VISIBLE) | WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_STATIC_2), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_STATIC_2), GWL_STYLE) | WS_VISIBLE) & ~WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_OVER_1), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_OVER_1), GWL_STYLE) & ~WS_VISIBLE) | WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_OVER_2), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_OVER_2), GWL_STYLE) | WS_VISIBLE) & ~WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_TEXT_1), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_TEXT_1), GWL_STYLE) & ~WS_VISIBLE) | WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_TEXT_2), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_TEXT_2), GWL_STYLE) | WS_VISIBLE) & ~WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON1_1), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON1_1), GWL_STYLE) & ~WS_VISIBLE) | WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON1_2), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON1_2), GWL_STYLE) | WS_VISIBLE) & ~WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON2_1), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON2_1), GWL_STYLE) & ~WS_VISIBLE) | WS_DISABLED );
SetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON2_2), GWL_STYLE, (GetWindowLong(GetDlgItem(hwndDlg, IDC_BUTTON2_2), GWL_STYLE) | WS_VISIBLE) & ~WS_DISABLED );
InvalidateRect(hwndDlg, 0, TRUE);
SetWindowPos(hwndDlg, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSIZE);
}
if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON1_2)
{
DestroyWindow(hwndDlg);
}
break;
}
return DefWindowProc(hwndDlg, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, INT nCmdShow)
{
InstanceHandle = hInstance;
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = DialogProc;
wc.hInstance = InstanceHandle;
wc.hbrBackground = (HBRUSH )(COLOR_BTNFACE + 1);
wc.lpszClassName = "WhateverClass";
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
if(!RegisterClass(&wc))
return FALSE;
HWND WindowHandle = CreateWindow("WhateverClass",
"Whatever", // Caption text
WS_MINIMIZEBOX | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_CAPTION | WS_BORDER | WS_SYSMENU,
100, 100, 500, 600, // Position
NULL,
NULL,
InstanceHandle,
0);
MSG Msg;
while(GetMessage(&Msg, WindowHandle, 0, 0xFFFF) > 0)
{
if(!IsDialogMessage(WindowHandle, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return 0;
}