Ok tak men jeg får stadig fejl:
C:\\BORLAND\\BCC55\\BIN>makeobj cpp/test
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
cpp/test.cpp:
Error E2034 cpp/test.cpp 82: Cannot convert 'std::string' to 'unsigned int' in f
unction __stdcall MainWndProc(HWND__ *,unsigned int,unsigned int,long)
Error E2342 cpp/test.cpp 82: Type mismatch in parameter 'uValue' (wanted 'unsign
ed int', got 'std::string') in function __stdcall MainWndProc(HWND__ *,unsigned
int,unsigned int,long)
*** 2 errors in Compile ***
koden:
#include <windows.h>
#include <string>
HINSTANCE InstanceHandle;
HWND MainWindow;
std::string passwd = "abc123";
std::string wrong = "Forkert password prøv igen!";
char inputpasswd[256];
enum numbers {
text1 = 1000,
text2,
input1,
button1,
};
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CREATE:
CreateWindow("STATIC",
"Computeren er låst skriv adgangskoden for at få adgang!",
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 30, 800, 20,
hwnd,
(HMENU) (text1),
InstanceHandle,
0);
CreateWindow("STATIC",
"",
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 5, 800, 20,
hwnd,
(HMENU) (text2),
InstanceHandle,
0);
CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"",
WS_CHILD | WS_VISIBLE,
5, 60, 300, 20,
hwnd,
(HMENU) (input1),
InstanceHandle,
0);
CreateWindow("BUTTON",
"OK!",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
5, 85, 40, 30,
hwnd,
(HMENU) (button1),
InstanceHandle,
0);
break;
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == button1)
{
GetDlgItemText(hwnd, input1, inputpasswd, FALSE);
if(passwd == inputpasswd) {
DestroyWindow(hwnd);
}
else {
SetDlgItemInt(hwnd, text2, wrong, TRUE);
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
HWND CreateMainWindow()
{
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
wc.lpfnWndProc = (WNDPROC )MainWndProc;
wc.hInstance = InstanceHandle;
wc.hbrBackground = (HBRUSH )(COLOR_BTNFACE + 1);
wc.lpszClassName = "SimpleWinWndClass";
wc.lpszMenuName = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClass(&wc))
return 0;
return CreateWindow("SimpleWinWndClass",
"Computer-Lock",
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
WS_CAPTION | WS_BORDER | WS_THICKFRAME,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
0,
0,
InstanceHandle,
0);
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
INT nCmdShow)
{
InstanceHandle = hInstance;
if((MainWindow = CreateMainWindow()) == (HWND )0)
{
MessageBox(0, "Failed to create MainWindow!", "Warning", MB_OK);
return 0;
}
ShowWindow(MainWindow, SW_MAXIMIZE);
MSG Msg;
while(GetMessage(&Msg, 0, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}