1. RE: bad bug continued
- Posted by Bernie Ryan <xotron at localnet.com> Aug 10, 2001
- 411 views
George Walters wrote: > Irv and Derek, > George: Here is the a simple shell execute program that uses my Library maybe you could try this. --------------- CODE ------------------------- include w32engin.ew include dll.e atom not_running not_running = 1 -- Define the Main CallBack Procedure to respond to messages from Windows. function MainProc(HWND hWnd,UINT message,WPARAM wParam, LPARAM lParam) -- Declare the variables. UINT case RESULT ok -- The message switch. case = message -- Respond to the messages received from Windows. if case = WM_DESTROY then -- Received message to Shutdown. PostQuitMessage(0) -- Tell windows to close the Application. elsif case = WM_COMMAND then if not_running then -- only execute once -- ok = ShellExecuteA({hWnd,sz("open"),sz("exw.exe"), sz("d:/euphoria/training/arf020.exw"), sz("d:/euphoria/training"), SW_SHOWNORMAL}) -- not_running = 0 else return DefWindowProcA({hWnd,message,wParam,lParam}) end if else -- Default Built-in Window Procedure will Respond to any other messages return DefWindowProcA({hWnd,message,wParam,lParam}) end if return 0 -- Euphoria needs to have a function return something. end function -- The Main Window. procedure MainWindow() -- Declare the variables RESULT ok HWND hWnd HWND hDefPushbutton WNDCLASS wc MSG msg -- Define the class -- Declare the window class structure & initialize the members wc = struc({"WNDCLASS",{OR({CS_HREDRAW,CS_VREDRAW}), -- Class and Styles -- Tell Windows where to send callback messages for this Class call_back(routine_id("MainProc")), -- Callback Procedure 0,0,0, -- Not needed LoadIconA({0,IDI_APPLICATION}), -- Default icon LoadCursorA({0,IDC_ARROW}), -- Default Cursor COLOR_WINDOW+1, -- Background Color sz("Menu"), -- szpointer Menu name sz("SimpleClass")}}) -- szpointer Class name -- Register the class that was just defined. ok = RegisterClassA(wc) -- Create an instance of the Registered Class hWnd = CreateWindowA({sz("SimpleClass"), -- szpointer Class name sz(" Generic Simple Window"), -- szPointer Window Title WS_OVERLAPPEDWINDOW, -- Window style 200,100,400,300, -- X, Y, Width, Height 0,0,THIS_PROGRAM,0}) -- Create a Push button hDefPushbutton = CreateWindowA({sz("button"), sz("Execute"), OR({WS_CHILD,WS_VISIBLE, BS_DEFPUSHBUTTON}), 50,50,70,25, hWnd, IDOK, THIS_PROGRAM,0}) -- Display the window ok = ShowWindow({hWnd,SW_SHOWNORMAL}) -- Paint the client area by sending WM_PAINT to the Window ok = UpdateWindow(hWnd) -- Declare a message structure. msg = struc("MSG") -- Create the message loop. -- Retrieve a message from the Windows message queue -- and copys it to an MSG structure. while GetMessageA({msg,0,0,0}) do -- Translate any virtual-key messages -- to the real keys ok = TranslateMessage(msg) -- Dispatch the message to the handle -- specified in MSG structure ok = DispatchMessageA(msg) end while -- end procedure MainWindow() ---------------- End Code -------------------- Bernie