Fenster ohne WindowClose nicht mehr anzeigen
-
Hallo,
wie meine frage schon andeuten lässt, wollte ich mal fragen ob es noch eine andere möglichkeit gibt ein Fenster ohne WindowClose( ) nicht mehr anzuzeigen.Vieleicht durch irgendeine Sendmessage, ich wüsste jetzt aber nicht welche. Daher meien Frage an euch, wisst ihr das etwas schöneres als das brutale WindowClose()??
EDIT:Will meine Frage mal spezieller stellen, wie kann ich es machen, das wenn nach einem button klick das Parentwindow geschlossen/ oder einfach nicht mehr sichtbar is(kein minimieren) und dafür dann das childwindow auftaucht. und genauso andersherum, wie, wenn im childwindow ein button gedrückt wurde, und diese dann ausgeblendet wird und das parent wieder auftaucht??hoffe es war verständlich?
-
ShowWindow(my_window, SW_HIDE);
-
ahh ok, danke drako... das wars
danke vielmalsEDIT:naja vieleicht wars das doch noch nicht ganz. Wie kann ich es jetzt gestalten wenn mein childwindow aufgerufen wurde, und ich dort auf einen button drücke, das das alte vorher versteckte Parentwindow wieder angezeigt wird, weil ich kann in meinem window nicht auf das parent zugreifen??
-
ShowWindow(GetParent(GetParent(my_Window)), SW_SHOW);
-
heyho nochmal irgendwie klappt das nicht so ganz hier mal mein code.
eigentliche "childwindow"
#include "Includes.h" LRESULT CALLBACK New_Window_Procedure (HWND , UINT , WPARAM , LPARAM ); HWND ParentWindow; int Neue_Ueberweisung_Fenster(HINSTANCE ParentInstance,HWND ParentWindow) { char ChildWindowClassName[ ] = "ChildWindow"; HWND ChildWindow; /* This is the handle for our window */ MSG ChildWindowMsg; /* Here messages to the application are saved */ WNDCLASS ChildWindowClass; /* Data structure for the windowclass */ HBRUSH background = CreateSolidBrush(RGB(255,222,173)); ChildWindowClass.cbClsExtra = 0; ChildWindowClass.cbWndExtra = 0; ChildWindowClass.hbrBackground = background; ChildWindowClass.hCursor = LoadCursor(NULL,IDC_ARROW); ChildWindowClass.hIcon = LoadIcon(NULL,IDI_APPLICATION); ChildWindowClass.hInstance = ParentInstance; ChildWindowClass.lpfnWndProc = New_Window_Procedure; ChildWindowClass.lpszClassName = ChildWindowClassName; ChildWindowClass.lpszMenuName = MAKEINTRESOURCE(301); ChildWindowClass.style = CS_HREDRAW | CS_VREDRAW; if( !RegisterClass(&ChildWindowClass) ) { MessageBox(NULL,"Fensterklasse konnte nicht registriert werden!","Fehler",MB_OK); return 1; } ChildWindow = CreateWindowEx(NULL, ChildWindowClassName, "Neue Überweisung", WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, HEIGHT-200, WIDTH-200, ParentWindow, NULL, ParentInstance, NULL); if( !ChildWindow ) { MessageBox(NULL,"Fenster konnte nicht erstellt werden","Fehler",MB_OK); return 2; } ShowWindow(ChildWindow,SW_SHOWNORMAL); UpdateWindow(ChildWindow); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&ChildWindowMsg, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&ChildWindowMsg); /* Send message to WindowProcedure */ DispatchMessage(&ChildWindowMsg); } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return (int)ChildWindowMsg.wParam; } LRESULT CALLBACK New_Window_Procedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_DESTROY: { DestroyWindow(hwnd); PostQuitMessage(0); } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDM_ZUREUCK: { //ShowWindow(hwnd,SW_HIDE); WinMain((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE), (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),"Test",SW_SHOW); //ShowWindow(GetParent(GetParent(hwnd)),SW_SHOW); break; } }//ende switch(LOWORD(wParam) }//ende WM_COMMAND default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }hier is das mainwindow.
#include "Includes.h" LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); HINSTANCE hinst; /* Make the class name into a global variable */ char szClassName[ ] = "Kontosimulation"; int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nCmdShow) { RECT ScreenCoords; if(!SystemParametersInfo(SPI_GETWORKAREA,NULL,&ScreenCoords,NULL) ) { MessageBox(NULL,"Achtung","Ein Fehler",MB_ICONWARNING | MB_OK | MB_DEFBUTTON1); ScreenCoords.right = 1024; ScreenCoords.bottom = 768; } 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_HREDRAW|CS_VREDRAW; /* 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 = MAKEINTRESOURCE(302); /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default colour as the background of the window */ wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); /* 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 = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "Kontosimulation", /* Title Text */ WS_CAPTION|WS_SYSMENU|WS_DLGFRAME, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ HEIGHT-200, /* The programs width */ WIDTH-200, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, nCmdShow); hinst = hThisInstance; /* 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; } LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND Eeditfield; HWND Anmelden; HWND Bbeenden; int width; int height; switch (message) /* handle the messages */ { case WM_DESTROY: PostQuitMessage (0); DestroyWindow(hwnd); break; case WM_SIZE: { width = LOWORD(lParam); height = HIWORD (lParam); } case WM_PAINT: { PAINTSTRUCT ps; RECT ClientArea; GetClientRect(hwnd,&ClientArea); HDC hDc = BeginPaint(hwnd,&ps); { SetBkMode(hDc,TRANSPARENT); TextOut(hDc, 10, 5*VABSTAND, "Benutzer:", 9); //DrawLine(hwnd,PS_SOLID,1,RGB(122,122,122),0,height-40,width,height-40); } } case WM_CREATE: { Eeditfield = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 5*HABSTAND+30, 5*VABSTAND, 150, 20, hwnd, (HMENU)EDITFIELD, (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE), NULL); //SendMessage(Eeditfield,EM_SETREADONLY,true,0); Anmelden= CreateWindow("button", "Anmelden", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 5*HABSTAND+60, 5*VABSTAND+40, 80, 20, hwnd, (HMENU)BT_ANMELDEN, (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE), NULL); /* Bbeenden = CreateWindow("button", "Beenden", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 50*HABSTAND+30, 50*VABSTAND+55, 80, 20, hwnd, (HMENU)BEENDEN, (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE), NULL);*/ } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDM_NEUE_UEBERWEISUNG: { break; } case IDM_SCHLIESSEN: { DestroyWindow(hwnd); PostQuitMessage(0); break; } case BT_ANMELDEN: { MessageBox(hwnd,"Sie haben sich erfolgreich angemeldet, ihnen stehen nun weitere Möglichkeiten zur verfügung","Hinweis",MB_ICONINFORMATION); Neue_Ueberweisung_Fenster((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),hwnd); break; } }//ende switch(LOWORD(wparam) }//ende WM_COMMAND default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }soo und in dem
case IDM_ZURUECK:soll dann das mainwindow wieder angezeigt werden.
Das was ich jetzt hinbekommen habe ist, das das Mainwindow ausgeblendet wird, aber ich möchte das es auch wieder eingeblendet wird.?? kann mir da einer weiterhelfen?
-
1.: ShowWindow(GetParent(hWnd), SW_SHOW);
2.:
WTF?
WinMain((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE), (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),"Test",SW_SHOW);OMFG -.-
-
ja sorry, bin in winapi noch nich so auf der höhe...aber ich wollte einfach wieder das mainwindow aufrufen, so wie ich es mit dem child gemacht habe.aber mit showwindow wie du es geschrieben hast, funktioniert es leider nicht??
-
wie lässt du denn das Parent überhaupt verschwinden?
-
nee ich habs jetzt soweit hinbekommen...ich hatte es mit SW_HIDE verschwinden lassen, aber ich habe es jetzt wie gesagt so gut wie hinbekommen. danke