begge dele
case WM_KEYDOWN
switch(wParam)
{
case WM_CHAR:
}
Men har et problem:
Hvordan får jeg skrevet det til en fil?
Min kode:
#include <windows.h>
#include <iostream>
#include <fstream>
enum WindowsId
{
FirstEditId = 256,
SecondEditId,
ResultEditId,
ButtonId
};
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow);
void getKey();
HINSTANCE hInsta;
WPARAM wParameter;
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
wParameter = wParam;
switch(nMsg)
{
case WM_CREATE:
{
CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"",
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_GROUP,
250, 20, 500, 600,
hwnd,
(HMENU)(FirstEditId),
hInsta,
0);
}
break;
case WM_KEYDOWN:
{
getKey();
switch(wParam)
{
case WM_CHAR:
{
}
break;
case VK_UP:
PostQuitMessage(0);
break;
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, nMsg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
{
hInsta = hInst;
WNDCLASSEX wc;
memset(&wc, 0, sizeof(WNDCLASSEX));
wc.lpszClassName = "MainWindow";
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.hInstance = hInst;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
RegisterClassEx(&wc);
HWND Window = CreateWindow("MainWindow","Trace It!", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT , CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL);
MSG msg;
ShowWindow(Window, nShow);
UpdateWindow(Window);
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
void getKey()
{
std::ifstream fil("D:\\\\test.txt");
if(char(wParameter) == 'A')
{
char cha = 'a';
fil << 123;
}
if(char(wParameter) == 'B')
{
fil >> "b";
}
if(char(wParameter) == 'C')
{
fil >> "c";
}
if(char(wParameter) == 'D')
{
fil >> "d";
}
if(char(wParameter) == 'E')
{
fil >> "e";
}
if(char(wParameter) == 'F')
{
fil >> "f";
}
if(char(wParameter) == 'G')
{
fil >> "g";
}
if(char(wParameter) == 'H')
{
fil >> "h";
}
if(char(wParameter) == 'I')
{
fil >> "i";
}
if(char(wParameter) == 'J')
{
fil >> "j";
}
if(char(wParameter) == 'K')
{
fil >> "k";
}
if(char(wParameter) == 'L')
{
fil >> "l";
}
if(char(wParameter) == 'M')
{
fil >> "m";
}
if(char(wParameter) == 'N')
{
fil >> "n";
}
if(char(wParameter) == 'O')
{
fil >> "o";
}
if(char(wParameter) == 'P')
{
fil >> "p";
}
if(char(wParameter) == 'Q')
{
fil >> "q";
}
if(char(wParameter) == 'R')
{
fil >> "r";
}
if(char(wParameter) == 'S')
{
fil >> "s";
}
if(char(wParameter) == 'T')
{
fil >> "t";
}
if(char(wParameter) == 'U')
{
fil >> "u";
}
if(char(wParameter) == 'V')
{
fil >> "v";
}
if(char(wParameter) == 'W')
{
fil >> "w";
}
if(char(wParameter) == 'X')
{
fil >> "x";
}
if(char(wParameter) == 'Y')
{
fil >> "y";
}
if(char(wParameter) == 'Z')
{
fil >> "z";
}
}