Page 2 of 2

Posted: Thu Mar 06, 2008 2:21 am
by Pelluso
It is still flickering !

The child window "opens" with its original size then resizes causing flickering !

I will try something later ...

Posted: Thu Mar 06, 2008 3:11 am
by Sparkie
Try this for no flickering...

Code: Select all

Procedure JanelaHistoricos() 
  SendMessage_(WindowID(#Window_0), #WM_SETREDRAW,0,0) 
  AddGadgetItem(#MDIGadget,#Historicos,"Históricos",0,#PB_Window_Invisible|#PB_Window_MinimizeGadget|#PB_Window_BorderLess)  
  ResizeWindow(#Historicos,#PB_Ignore,#PB_Ignore,400,200) 
  SendMessage_(WindowID(#Window_0), #WM_SETREDRAW,1,0) 
  HideWindow(#Historicos,0) 
EndProcedure 

Posted: Thu Mar 06, 2008 5:20 am
by netmaestro
I currently have several applications that use MDI and all of them use a custom size and position for the created childs. The method I show here is pretty much exactly how my programs do it:

Code: Select all

Global hook, childw, childh

Procedure CbtProc(nCode, wParam, lParam) 
  Select nCode 
    Case #HCBT_CREATEWND 
      hWnd = wParam 
      *pcbt.CBT_CREATEWND = lParam 
      *pcs.CREATESTRUCT = *pcbt\lpcs
      *pcs\cx = childw
      *pcs\cy = childh
   EndSelect 
  ProcedureReturn CallNextHookEx_(hook, nCode, wParam, lParam) 
 EndProcedure 
 
OpenWindow(0,0,0,800,600,"Flicker-free custom MDI windows",#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
CreateMenu(0, WindowID(0))
 MenuTitle("File")
   MenuItem(0, "MDI Window that does something")
   MenuItem(99, "Exit")
 MenuTitle("Window")

MDIGadget(0,0,0,0,0,1,100,#PB_MDI_AutoSize)

quit=#False
Repeat
  EventID = WaitWindowEvent()
  Select EventID
    Case #PB_Event_Menu
      Select EventMenu()
        Case 0
          If Not IsWindow(1)
            childw = 512
            childh = 512
            hook = SetWindowsHookEx_(#WH_CBT, @CbtProc(), #Null, GetCurrentThreadId_()) 
            AddGadgetItem(0,1,"Custom Sized MDI Child")
            UnhookWindowsHookEx_(hook)
          Else
            SetActiveWindow(1)  
          EndIf       
        Case 99
          quit=#True
      EndSelect
    Case #PB_Event_CloseWindow
      Select EventWindow()
        Case 0
          quit=#True
        Default
          CloseWindow(EventWindow())
      EndSelect
  EndSelect
Until quit

Posted: Thu Mar 06, 2008 10:46 am
by srod
Pelluso wrote:Did not worked !

That a look !

Click Cadastro->Históricos
You didn't implement what I put into my last snippet! :roll:

Sparkie and Baldrick did. Only tested Sparkie's and it works fine here.

Posted: Thu Mar 06, 2008 11:32 pm
by Pelluso
Thank you all !

Netmaestro , Sparkie , Srod , Baldrick !

Now everything is OK !

Cheers

Posted: Fri Mar 07, 2008 2:36 am
by Pelluso
Netmaestro your code is greate !

I added another menu item and checked that this is not working

Code: Select all

SetActiveWindow(1)
and changed with this

Code: Select all

SetGadgetState(0,1)
and is working pretty well

thanks