neues fenster zeichnen
-
wie viele fenster kann ich so offenhalten ohne den pc zu überlasten?
Also ich habs noch net ausprobiert... so ca. 100000 ?!
Ne mal im ernst... kommt immer darauf an was innerhalb des Dialogs gemacht wird... bsw CPU fressende Berechnungnen in mehreren Dialogen nebeneinander... na ich weiß net 
Also einen Window kannst du mit CreateWindow erstellen... wo ist dein Problem?
-
ich weiß nicht wo ichs in die winmain stecken soll
-
is doch egal?! am besten an den anfang
-
soll ich mit einer ifabfrage reagieren? wenn ja die variable ist in meiner fensterfunktion wie soll ich sie ins winmain schaffen?
-
#include <windows.h> long __stdcall WndProc(::HWND__*, unsigned int, unsigned int, long); int __stdcall WinMain(::HINSTANCE__* hInstance, ::HINSTANCE__* hPrevInstance, LPSTR szCmdLine, int iCmdShow) { ::HWND__* hWnd; ::MSG msg; ::WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wc.hIcon = ::LoadIcon(NULL, IDI_APPLICATION); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszClassName = "Test"; wc.lpszMenuName = NULL; ::RegisterClass(&wc); hWnd = ::CreateWindow("Test", "Meine 1. Anwendung", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ::ShowWindow(hWnd, iCmdShow); ::UpdateWindow(hWnd); while (::GetMessage(&msg, NULL, 0, 0)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } return msg.wParam; } long __stdcall WndProc(::HWND__* hWnd, unsinged int message, unsigned int wParam, long lParam) { switch (message) { case WM_CREATE: { // ... Hier kannst de dir bsw auch nochmal ein neues Fenster mit CreateWindow erstellen. usw :... } case WM_DESTROY: { PostQuitMessage(0); return 0; } } return (long)DefWindowProc(hWnd, message, wParam, lParam); }
-
das meine ich: wenn ich das da mache meckert er bei der hInstance rum. wenn ich dann das fenster nochmal neu in einer funktion definiere mit windowsclass und dem rest dann mekert er auch an der stelle rum. das ist ja mein problem. soll ich vielleicht mal einen code posten?
-
wäre hilfreich -.- und mal die genaue Fehlermeldung...
-
#include <windows.h> long __stdcall WndProc(::HWND__*, unsigned int, unsigned int, long); char szPrgm[] = "test2"; bool MakeWindow(int iWidth, int iHeight) { HINSTANCE hInstance; WNDCLASS wndWc; wndWc.style = CS_OWNDC; wndWc.lpfnWndProc = (WNDPROC) WndProc; wndWc.cbClsExtra = 0; wndWc.cbWndExtra = 0; wndWc.hInstance = GetModuleHandle(NULL); wndWc.hIcon = ::LoadCursor(NULL, IDC_ARROW); wndWc.hCursor = ::LoadIcon(NULL, IDI_APPLICATION); wndWc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndWc.lpszMenuName = NULL; wndWc.lpszClassName = szPrgm; if (!RegisterClass(&wndWc)) return false; int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); // width int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN); // height RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight }; hWnd = CreateWindow(szPrgm, TEXT("Calculator 1.4"), WS_SYSMENU, rc.left,rc.top, iWidth,iHeight, NULL, NULL, GetModuleHandle(NULL), NULL); return (hWnd?true:false); } int __stdcall WinMain(::HINSTANCE__* hInstance, ::HINSTANCE__* hPrevInstance, LPSTR szCmdLine, int iCmdShow) { ::HWND__* hWnd; ::MSG msg; ::WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wc.hIcon = ::LoadIcon(NULL, IDI_APPLICATION); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszClassName = "Test"; wc.lpszMenuName = NULL; ::RegisterClass(&wc); hWnd = ::CreateWindow("Test", "Meine 1. Anwendung", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ::ShowWindow(hWnd, iCmdShow); ::UpdateWindow(hWnd); while (::GetMessage(&msg, NULL, 0, 0)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } return msg.wParam; } long __stdcall WndProc(::HWND__* hWnd, unsigned int message, unsigned int wParam, long lParam) { switch (message) { case WM_CREATE: { } case WM_DESTROY: { PostQuitMessage(0); return 0; } } return (long)DefWindowProc(hWnd, message, wParam, lParam); }So jetzt habe ich nur noch hWnd den fehler hWnd undeclared, sonst funktioniert es. ich möchte dann einfach die funktion aufrufen (das geht oder oder)?
-
*edit: hauptteil hab ich auf ner opensourcepage gefunden
-
natürlich beschwert er sich da, du hast hWnd ja auch nirgends deklariert in deiner MakeWindow funktion...
-
#include <windows.h> char szPrgm[] = "abc"; static HBRUSH MyBrush; bool MakeWindowSmall(int iWidth, int iHeight) { HINSTANCE hInstance; WNDCLASS wndWc; wndWc.style = CS_OWNDC; wndWc.lpfnWndProc = (WNDPROC) WndProc; wndWc.cbClsExtra = 0; wndWc.cbWndExtra = 0; wndWc.hInstance = GetModuleHandle(NULL); wndWc.hIcon = LoadIcon (GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON)); wndWc.hCursor = LoadCursor (GetModuleHandle(NULL),MAKEINTRESOURCE(IDC_CURSOR)); wndWc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndWc.lpszMenuName = szPrgm; wndWc.lpszClassName = szPrgm; if (!RegisterClass(&wndWc)) return false; int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); // width int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN); // height RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight }; hWnd = CreateWindow(szPrgm, TEXT("abc"), WS_SYSMENU, rc.left,rc.top, iWidth,iHeight, NULL, NULL, GetModuleHandle(NULL), NULL); ShowWindow(hWnd, SW_SHOW); return (hWnd?true:false); } bool MakeWindowCompact(int iWidth, int iHeight) { HINSTANCE hInstance; ::HWND__* hWnds; WNDCLASS wndWc; wndWc.style = CS_OWNDC; wndWc.lpfnWndProc = (WNDPROC) WndProc; wndWc.cbClsExtra = 0; wndWc.cbWndExtra = 0; wndWc.hInstance = GetModuleHandle(NULL); wndWc.hIcon = ::LoadCursor(NULL, IDC_ARROW); wndWc.hCursor = ::LoadIcon(NULL, IDI_APPLICATION); wndWc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndWc.lpszMenuName = NULL; wndWc.lpszClassName = szPrgm; if (!RegisterClass(&wndWc)) return false; int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); // width int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN); // height RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight }; hWnds = CreateWindow(szPrgm, TEXT("Calculator 1.4"), WS_SYSMENU, rc.left,rc.top, iWidth,iHeight, NULL, NULL, GetModuleHandle(NULL), NULL); ShowWindow(hWnds, SW_SHOW); return (hWnds?true:false); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, \ LPSTR lpCmdLine, int nCmdShow) { if( !MakeWindowSmall(200,250)) return -1; MSG mMsg; while (1) { if(PeekMessage(&mMsg, 0, 0, 0, PM_REMOVE)) { if(mMsg.message == WM_QUIT) { break; } TranslateMessage(&mMsg); DispatchMessage(&mMsg); } } DestroyWindow(hWnd); return 0; } LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { HMENU hMenu; switch(uMessage) { case WM_CREATE: return 0; case WM_COMMAND: hMenu = GetMenu(hWnd); switch( LOWORD (wParam)) { case IDM_WM_small: { MakeWindowSmall(200,250); break; } case IDM_WM_compact: { MakeWindowCompact(200,450); break; } case IDM_WM_EXIT: { PostQuitMessage(0); return 0; } case WM_DESTROY: { DeleteObject(MyBrush); PostQuitMessage (0); return 0; } } return DefWindowProc(hWnd,uMessage,wParam,lParam); } LRESULT CALLBACK WndProc(HWND hWnds, UINT uMessage, WPARAM wParam, LPARAM lParam) { HMENU hMenu; switch(uMessage) { case WM_CREATE: return 0; case WM_COMMAND: hMenu = GetMenu(hWnds); switch( LOWORD (wParam)) { case IDM_WM_small: { MakeWindowSmall(200,250); break; } case IDM_WM_compact: { MakeWindowCompact(200,450); break; } case IDM_WM_EXIT: { PostQuitMessage(0); return 0; } case WM_DESTROY: { DeleteObject(MyBrush); PostQuitMessage (0); return 0; } } return DefWindowProc(hWnds,uMessage,wParam,lParam); }nun sollte er ja beim menüauswählen ein neues fenster öffnen, das macht er aber nicht
*kann sein das ich was kleines vergessen habe
aber meine version läuft