我创建了一个简单的Win32程序,它显示了两个文本编辑框,以及一个显示转换的按钮。
想法是用户应该在左侧框和右侧框中输入一系列数字,然后它应该输出一个.txt
文件,该文件与第一行匹配,每个框上的第一行。我希望这是有意义的,我会尝试以图形方式解释:
Edit Box One: | Edit Box 2: | Seperate .txt file (saved on desktop)
111 | 222 | 111,222
222 | 333 | 222,333
你可以看到这是我的最终目标,我可以在这里添加代码:
#include <windows.h>
#define IDC_BUTTON_ONE 101
#define IDC_EDITOR_BOX_EAST_WEST 102
#define IDC_EDITOR_BOX_NORTH_SOUTH 103
LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wClassEx;
ZeroMemory(&wClassEx, sizeof(WNDCLASSEX));
wClassEx.cbClsExtra = NULL;
wClassEx.cbSize = sizeof(WNDCLASSEX);
wClassEx.cbWndExtra = NULL;
wClassEx.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
wClassEx.hCursor = LoadCursor(hInst, IDC_ARROW);
wClassEx.hIcon = NULL;
wClassEx.hIconSm = NULL;
wClassEx.hInstance = hInst;
wClassEx.lpfnWndProc = (WNDPROC)WinProc;
wClassEx.lpszClassName = "Window Class";
wClassEx.lpszMenuName = NULL;
wClassEx.style = CS_HREDRAW | CS_VREDRAW;
if (!RegisterClassEx(&wClassEx))
{
int nResult = GetLastError();
MessageBox(NULL, "Class creation failed", "CLASS CREATION FAILURE", MB_ICONERROR);
}
HWND hWnd = CreateWindowEx(NULL, "Window Class", "Well Path Survey Convertor to Readable AutoCAD .SCR", WS_OVERLAPPEDWINDOW, 200, 200, 600, 490, NULL,
NULL, hInst, NULL);
if (!hWnd)
{
int nResult = GetLastError();
MessageBox(NULL, "Window creation failed", "WINDOW CREATION FAILURE", MB_ICONERROR);
}
ShowWindow(hWnd, nShowCmd);
MSG msg;
ZeroMemory(&msg, sizeof(MSG));
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CREATE:
{
HWND hWndButton = CreateWindowEx(NULL, "Button", "Click to Convert", WS_TABSTOP|WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
200, 370, 150, 50, hWnd, (HMENU)IDC_BUTTON_ONE, NULL, NULL);
HWND hEditEW = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "", WS_CHILD|ES_MULTILINE| WS_VISIBLE |
ES_AUTOHSCROLL | ES_AUTOVSCROLL, 25, 50, 220, 300, hWnd, (HMENU)IDC_EDITOR_BOX_EAST_WEST, NULL, NULL);
HWND hEditNS = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "", WS_CHILD | ES_MULTILINE | WS_VISIBLE |
ES_AUTOHSCROLL | ES_AUTOVSCROLL, 300, 50, 220, 300, hWnd, (HMENU)IDC_EDITOR_BOX_EAST_WEST, NULL, NULL);
}
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_BUTTON_ONE:
{
}
break;
}
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}