| Код | #include <windows.h> #include <iostream.h> #include <fstream.h> #include <string.h> using namespace std;
/* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */ #define IDS_APP_TITLE 103 #define MAX_LOADSTRING 100 #define IDB_ACCEPT 106 #define IDB_EDIT 107 #define IDC_WINDOWBASIC 109
// Global Variables: HINSTANCE hInst; // current instance
char szClassName[ ] = "WindowsApp"; HWND hWnd_Global; HWND hWnd_Btn; HWND hWnd_Edit; HWND hWnd_Edit1; HWND hWnd_Edit2; HWND hWnd_Label; HWND hWnd_Label1; HWND hWnd_Label2; WNDPROC wpOrigEditProc;
LRESULT CALLBACK EditWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return CallWindowProc(wpOrigEditProc, hwnd, uMsg, wParam, lParam); }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{ //HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0;
/* The class is registered, let's create the program*/ hWnd_Global = CreateWindow(szClassName, "cgpsmapper AUTOMAKE", WS_OVERLAPPEDWINDOW, 0, 0, 800, 600, NULL, NULL, hThisInstance, NULL); hWnd_Btn = CreateWindow("BUTTON", // predefined class "ACCEPT", // button text WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles // Size and position values are given explicitly, because // the CW_USEDEFAULT constant gives zero values for buttons. 100,150,120,25, // set size in WM_SIZE message hWnd_Global, // parent window NULL, // No menu (HINSTANCE) GetWindowLong(hWnd_Global, GWL_HINSTANCE), NULL); // pointer not needed SetWindowLong(hWnd_Btn,GWL_ID,IDB_ACCEPT); hWnd_Edit = CreateWindow("EDIT", // predefined class "GlobalMapDefault", // no window title WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT, 150, 15, 250, 25, // set size in WM_SIZE message hWnd_Global, // parent window NULL, // edit control ID (HINSTANCE) GetWindowLong(hWnd_Global, GWL_HINSTANCE), NULL); // pointer not needed hWnd_Label = CreateWindow("STATIC", // predefined class "Íàçâàíèå êàðòû", // no window title WS_CHILD | WS_VISIBLE | ES_LEFT, 10, 15, 120, 25, // set size in WM_SIZE message hWnd_Global, // parent window NULL, // edit control ID (HINSTANCE) GetWindowLong(hWnd_Global, GWL_HINSTANCE), NULL); // pointer not needed hWnd_Edit1 = CreateWindow("EDIT", // predefined class "0", // no window title WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT, 150, 55, 250, 25, // set size in WM_SIZE message hWnd_Global, // parent window NULL, // edit control ID (HINSTANCE) GetWindowLong(hWnd_Global, GWL_HINSTANCE), NULL); // pointer not needed hWnd_Label1 = CreateWindow("STATIC", // predefined class "Product Code", // no window title WS_CHILD | WS_VISIBLE | ES_LEFT, 15, 55, 120, 25, // set size in WM_SIZE message hWnd_Global, // parent window NULL, // edit control ID (HINSTANCE) GetWindowLong(hWnd_Global, GWL_HINSTANCE), NULL); // pointer not needed hWnd_Edit2 = CreateWindow("EDIT", // predefined class "C:\\Mapsoft\\Default.img", // no window title WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT, 150, 95, 250, 25, // set size in WM_SIZE message hWnd_Global, // parent window NULL, // edit control ID (HINSTANCE) GetWindowLong(hWnd_Global, GWL_HINSTANCE), NULL); // pointer not needed hWnd_Label2 = CreateWindow("STATIC", // predefined class "File Name", // no window title WS_CHILD | WS_VISIBLE | ES_LEFT, 15, 95, 120, 25, // set size in WM_SIZE message hWnd_Global, // parent window NULL, // edit control ID (HINSTANCE) GetWindowLong(hWnd_Global, GWL_HINSTANCE), NULL); // pointer not needed SetWindowLong(hWnd_Edit,GWL_ID,IDB_EDIT); wpOrigEditProc = (WNDPROC) SetWindowLong(hWnd_Edit,GWL_WNDPROC, (LONG) EditWndProc); /* Make the window visible on the screen */ ShowWindow (hWnd_Global, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); }
/* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; }
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: if ((wmId==IDB_ACCEPT)&&(wmEvent == BN_CLICKED)) { char CardName[250]; char ProductCode[250]; char FileName[250]; char OutputFile[3000]; GetWindowText(hWnd_Edit,CardName,250); GetWindowText(hWnd_Edit1,ProductCode,250); GetWindowText(hWnd_Edit2,FileName,250); OutputFile = "[Map]\n"+"FileName="+CardName+"\n"+"MapVersion=100\n"+ "ProductCode="+ProductCode+"\n"+"Levels=2\n"+"Level0=15\n"+"Level1=13\n"+ "Zoom0=7\n"+"Zoom1=8\n"+"MapsourceName="+CardName+"\n"+"MapSetName="+CardName+"\n"+ "CDSetName="+CardName+"\n"+"Copy1=Garmin\n"+"Copy2=Garmin\n"+"[End-Map]\n\n"+ "[Files]\n"+"img="+FileName+"\n"+"[END-Files]"; FILE * fo; fo = fopen("pv.txt","wt"); while( !feof(fo) ) { fprintf( fo, "%d\n", OutputFile ); } } case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;
}
|
Выдаёт следующее:
2 C:\Dev-Cpp\include\c++\3.4.2\backward\fstream.h:31, from main.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/fstream.h:31, from main.cpp 32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. C:\Dev-Cpp\main.cpp In function `LRESULT WindowProcedure(HWND__*, UINT, WPARAM, LPARAM)':
184 C:\Dev-Cpp\main.cpp invalid operands of types `const char[7]' and `const char[10]' to binary `operator+' C:\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1
По поводу строк: оператор + в строках не используется? |