*   >> Lectura Educación Artículos >> science >> programación

Ventanas predefinidas Controls

ntrol de edición. El control de edición es la ventana secundaria y su identificador de ventana de los padres es, hwndMain. #include using namespace std; LRESULT CALLBACK MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, lParam LPARAM) {switch (uMsg) {default: regresan DefWindowProc (hwnd, uMsg, wParam, lParam); } Return 0; } Int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {WCX WNDCLASSEX; wcx.cbSize = sizeof (WCX); wcx.style = CS_HREDRAW | CS_VREDRAW; wcx.lpfnWndProc = MainWndProc; wcx.cbClsExtra = 0; wcx.cbWndExtra = 0; wcx.

hInstance = hInstance; wcx.hIcon = NULL; wcx.hCursor = LoadCursor (NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH) (COLOR_BACKGROUND + 1); wcx.lpszMenuName = NULL; wcx.lpszClassName = "MainWClass"; wcx.hIconSm = NULL; RegisterClassEx (y WCX); HWND hwndMain; hwndMain = CreateWindowEx (0, "MainWClass", "Ventana principal", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); si (hwndMain!) return false; ShowWindow (hwndMain, SW_SHOW); UpdateWindow (hwndMain); HWND hwndEdit1; hwndEdit1 = CreateWindowEx (0, "EDIT", "Edición de prueba", WS_CHILD, 100, 100, 150, 15, hwndMain, (HMENU) 1, hInstance, NULL); ShowWindow (hwndEdit1, SW_SHOW); UpdateWindow (hwndEdit1); Msg MSG; BOOL Bret; while ((Bret = GetMessage (y msg, hwndMain, 0, 0)) = 0!) {if (Bret == -1) {//manejar el error y posiblemente salir de la aplicación} else {TranslateMessage (y msg); DispatchMessage (y msg); }} Return msg.

wParam; } Guarde el código en un archivo de texto con el nombre winedit.cpp en el directorio MinGW. Pruebe el código de arriba para ver lo que se ve el control de edición similares. Pruébalo en la ventana de símbolo del sistema en el directorio MinGW con el siguiente comando: g ++ winedit.cpp -mwindows -o winedit.exe Después de esto, haga doble clic en el icono, winapp.exe en la carpeta winapp.exe, para ver la ventana y control de edición.

El segmento de código que crea el control de edición es, HWND hwndEdit1; hwndEdit1 = CreateWindowEx (0, "EDIT", "Edición de prueba", WS_CHILD, 100, 100, 150, 15, hwndMain, (HMENU) 1, hInstance, NULL); ShowWindow (hwndEdit1, SW_SHOW); UpdateWindow (hwndEdit1); Tenga en cuenta que el nombre, "Test Editar" dado al control de edición aparece como el texto inicial en el control de edición. Eso esta bien. Si usted no quiere ningún texto inicial, a continuación, establecer el nombre de la ventana secundaria a NULL. Puede selecciona

Page   <<  [1] [2] [3] [4] >>
Copyright © 2008 - 2016 Lectura Educación Artículos,https://lectura.nmjjxx.com All rights reserved.