Digisoul Posted May 7, 2010 Share Posted May 7, 2010 Hello ThereI am trying to make a multiple form program, but i have no idea that how can i take start,this is my first attempt & i am facing 2 basic problems, please see the images1: Focus Problemhttp://img24.imageshack.us/img24/8113/prob1nl.jpg2: Child windows Maximum State Problemhttp://img199.imageshack.us/img199/5769/prob2k.jpghttp://img199.imageshack.us/img199/2553/prob21.jpghttp://img200.imageshack.us/img200/2255/prob22.jpgHere is my code expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $hMian,$hChild[1],$tChild=1 $hMain = GUICreate("Parent Window", 633, 447, 192, 200) GUICtrlCreateLabel("",0,0,0,0) $mMain = GUICtrlCreateMenu("New") $mChild = GUICtrlCreateMenuItem("Child", $mMain) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $mChild CreateChild() EndSwitch WEnd Func CreateChild() $Child = GUICreate("Child "&$tChild,300,300,10,0, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_POPUP, $WS_SYSMENU)) GUISetState() _WinAPI_SetParent($Child,$hMain) Add($hChild,$Child) EndFunc Func Add(ByRef $Array,$V) If $Array[0] = "" Then $Array[0] = $V Else $p = UBound($Array) ReDim $Array[$p+1] $Array[$p] = $V EndIf $tChild +=1 EndFuncThanks in Advance 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Digisoul Posted May 7, 2010 Author Share Posted May 7, 2010 Any reference guys? 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 8, 2010 Moderators Share Posted May 8, 2010 (edited) Digisoul,Do not be impatient - please only bump your posts after 24 hrs. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually - like now! 1: Focus Problem. This question was asked here about a year ago and there was no solution. As far as I know Windows will only allow one window to have focus at any one time. I can only imagine that the application you show is a custom-built one which does not follow the normal Window API rules. 2: Child windows Maximum State Problem. Better news - some of this we can solve! - (a) No move when maximized. We need to intercept the SC_MOVE command when the Child is maximized. Here is a rough proof-of-concept script:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $hMian, $hChild[1], $tChild = 1, $SC_MOVE = 0xF010, $fChild_Max = False $hMain = GUICreate("Parent Window", 633, 447, 192, 200) GUICtrlCreateLabel("", 0, 0, 0, 0) $mMain = GUICtrlCreateMenu("New") $mChild = GUICtrlCreateMenuItem("Child", $mMain) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hMain ; Main GUI Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $mChild CreateChild() EndSwitch Case $hChild[0] Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($hChild[0]) Case $GUI_EVENT_MAXIMIZE $fChild_Max = True Case $GUI_EVENT_RESTORE $fChild_Max = False EndSwitch EndSwitch WEnd Func CreateChild() $Child = GUICreate("Child " & $tChild, 300, 300, 10, 0, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_POPUP, $WS_SYSMENU)) GUISetState() _WinAPI_SetParent($Child, $hMain) Add($hChild, $Child) EndFunc ;==>CreateChild Func Add(ByRef $Array, $V) If $Array[0] = "" Then $Array[0] = $V Else $p = UBound($Array) ReDim $Array[$p + 1] $Array[$p] = $V EndIf $tChild += 1 EndFunc ;==>Add Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) If $hWnd = $hChild[0] Then If $fChild_Max Then If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False EndIf EndIf Return $GUI_RUNDEFMSG EndFuncYou can see how we need to set a flag when the child is maximized, so that we can determine when SC_MOVE messages need to be blocked within the WM_SYSCOMMAND procedure. Obviously this would need to be a bit more complex if you wanted to have more than one child - you would need to do an _ArraySearch of $hChild both within the GUIGetMsg loop and the WM_SYSCOMMAND procedure - but that would not be too diffcult to code. - Cover parent menu bar. Another clue that the app you show does not follow the normal rules. I recently posted a workaround which gave a hideable menu bar - you might be able to modify this to do what you want. Edit: see below!I hope this gets you back on track. M23Edit: Here is a version with a menu which hides when you maximize the child:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $hMain, $hChild, $SC_MOVE = 0xF010, $fChild_Max = False ; Create main GUI $hMain = GUICreate("Parent Window", 633, 447, 192, 200) GUISetState(@SW_SHOW) ; Create Menu GUI Global $hMenu_Win = GUICreate("", 633, 20, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $hMain) ; Create menu Global $mFile_Menu = GUICtrlCreateMenu("&New") Global $hChild_Menu_Item = GUICtrlCreateMenuItem("&Child", $mFile_Menu) GUICtrlCreateMenuItem("", $mFile_Menu) Global $hExit_Menu_Item = GUICtrlCreateMenuItem("&Exit", $mFile_Menu) Global $mHelp_Menu = GUICtrlCreateMenu("&?") Global $hAbout_Menu_Item = GUICtrlCreateMenuItem("&About", $mHelp_Menu) ; Move to correct position Local $aWin_Pos = WinGetPos($hMain) Local $iBorder = _WinAPI_GetSystemMetrics(8) ; Border width Local $iBar = _WinAPI_GetSystemMetrics(4) ; Title bar height WinMove($hMenu_Win, "", $aWin_Pos[0] + $iBorder, $aWin_Pos[1] + $iBorder + $iBar) ; Show menu GUISetState(@SW_SHOW, $hMenu_Win) GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hMain ; Main GUI Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit EndSwitch Case $hMenu_Win _WinAPI_SetFocus($hMain) Switch $aMsg[0] Case $hExit_Menu_Item Exit Case $hChild_Menu_Item CreateChild() GUICtrlSetState($hChild_Menu_Item, $GUI_DISABLE) Case $hAbout_Menu_Item MsgBox(0, "Hello", "This is a better version of the script!") EndSwitch Case $hChild Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($hChild) GUICtrlSetState($hChild_Menu_Item, $GUI_ENABLE) Case $GUI_EVENT_MAXIMIZE $fChild_Max = True _Menu_State() Case $GUI_EVENT_RESTORE $fChild_Max = False _Menu_State() EndSwitch EndSwitch WEnd Func CreateChild() $hChild = GUICreate("Child", 300, 300, 10, 20, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_POPUP, $WS_SYSMENU)) GUISetState() _WinAPI_SetParent($hChild, $hMain) EndFunc ;==>CreateChild Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) If $hWnd = $hChild Then If $fChild_Max Then If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Func _Menu_State() If $fChild_Max Then GUISetState(@SW_HIDE, $hMenu_Win) Else GUISetState(@SW_SHOW, $hMenu_Win) EndIf EndFunc Edited May 8, 2010 by Melba23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Digisoul Posted May 9, 2010 Author Share Posted May 9, 2010 (edited) Thanks Melba23 for your kind reply,Btw i don't think so i bumped my post b4 24Hours. Edited May 9, 2010 by Digisoul 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 9, 2010 Share Posted May 9, 2010 Btw i don't think so i bumped my post b4 24Hours. But you are supposed to do it after. You really don't see the problem here? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now