Hi folks<br><br>I'm new in Win32 API programming and I have the following problem:<br><br>I have created a dialog with option fields where the user can set different options, and must press a OK-Button. The problem now is, that the OK-button don't works, and I don't know why.<br><br>Here the example of my code:<br><b><br>#include <windows.h><br>#include "resource.h"<br><br>HWND hwndModeless;<br>HINSTANCE hInst;<br><br><br>BOOL CALLBACK AboutDlgProc ( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )<br><font color=red>// About Window</font><br>{<br> switch ( message )<br> {<br> case WM_INITDIALOG:<br> return TRUE;<br><br> case WM_COMMAND:<br><br> switch ( LOWORD ( wParam ))<br> {<br> case IDOK:<br><br> EndDialog ( hDlg, 0 );<br> return TRUE;<br> }<br> break;<br> }<br> return FALSE;<br>}<br><br><br>BOOL CALLBACK MainDlg ( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )<br>{<br> switch ( message )<br> {<br> case WM_INITDIALOG:<br><br> CheckRadioButton ( hDlg, IDC_REBOOT, IDC_SHUTDOWN, 0 );<br> SendMessage ( hDlg, WM_COMMAND, IDOK, 0 );<br> } <br> return FALSE;<br>}<br><br>LRESULT CALLBACK WndProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )<br>{<br> switch ( message )<br> {<br> case WM_COMMAND:<br> <br> switch ( LOWORD ( wParam ))<br> {<br> case IDM_APP_ABOUT:<br><br> DialogBox ( hInst, MAKEINTRESOURCE ( IDD_ABOUT ), hwnd, AboutDlgProc );<br> return 0;<br><br> case IDOK:<br><br> switch ( LOWORD ( wParam ))<br> {<br> case IDC_REBOOT:<br> <br> ExitWindowsEx ( EWX_REBOOT, 0xFFFFFFFF );<br> return TRUE;<br><br> case IDC_SHUTDOWN:<br><br> ExitWindowsEx ( EWX_POWEROFF, 0xFFFFFFFF );<br> return TRUE;<br> }<br> <br> }<br> break;<br> <br> case WM_DESTROY:<br><br> PostQuitMessage ( 0 );<br> return 0;<br> }<br> return DefWindowProc ( hwnd, message, wParam, lParam );<br>}<br><br><br>int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, <br> PSTR szCmdLine, int iCmdShow )<br>{<br> TCHAR static szAppName [ ] = TEXT ( "SELECT" );<br> <br> HWND hwnd;<br> MSG msg;<br> RECT rect;<br> WNDCLASS wndclass;<br> <br> hInst = hInstance;<br><br> wndclass.style = 0;<br> wndclass.lpfnWndProc = WndProc;<br> wndclass.cbClsExtra = 0;<br> wndclass.cbWndExtra = 0;<br> wndclass.hInstance = hInstance;<br> wndclass.hIcon = LoadIcon ( hInstance, MAKEINTRESOURCE ( IDI_ICON2 ));<br> wndclass.hCursor = LoadCursor ( NULL, IDC_ARROW );<br> wndclass.hbrBackground = NULL;<br> wndclass.lpszMenuName = szAppName;<br> wndclass.lpszClassName = szAppName;<br><br> if ( !RegisterClass ( &wndclass )) <br> {<br> MessageBox ( NULL, TEXT ( "Only for Windows NT or Windows 2000" ), szAppName,<br> MB_ICONERROR );<br> return 0;<br> }<br><br> hwnd = CreateWindow ( szAppName, TEXT ( "Killing Windows" ), <br> WS_OVERLAPPED ¦ WS_CAPTION ¦ WS_SYSMENU ¦ WS_BORDER ¦ WS_MINIMIZEBOX,<br> CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, <br> NULL, NULL, hInstance, NULL ); <br> <br> hwndModeless = CreateDialog ( hInstance, szAppName, hwnd, MainDlg );<br><br> GetWindowRect ( hwndModeless, &rect );<br> AdjustWindowRect ( &rect, WS_CAPTION ¦ WS_BORDER, FALSE );<br><br> SetWindowPos ( hwnd, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE );<br><br> ShowWindow ( hwndModeless, SW_SHOW );<br> ShowWindow ( hwnd, iCmdShow );<br> UpdateWindow ( hwnd );<br><br> while ( GetMessage ( &msg, NULL, 0, 0 ))<br> {<br> if ( hwndModeless == 0 ¦¦ !IsDialogMessage ( hwndModeless, &msg ))<br> {<br> TranslateMessage ( &msg );<br> DispatchMessage ( &msg );<br> }<br> }<br> return msg.wParam;<br>}<br></b><br>And a other problem I have: the reboot and poweroff function don't works with WinNT and Win2k why?? Is there a option that I have forgot in my source?<br><br>At the moment I don't have any idea for my problem I hope you can help me.<br><br>Greeting SiM