MDIGadget "real world" example

Just starting out? Need help? Post your questions and find answers here.
Pelluso
User
User
Posts: 23
Joined: Tue Mar 23, 2004 9:04 pm
Location: Brazil

Post by Pelluso »

It is still flickering !

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

I will try something later ...
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
Pelluso
User
User
Posts: 23
Joined: Tue Mar 23, 2004 9:04 pm
Location: Brazil

Post by Pelluso »

Thank you all !

Netmaestro , Sparkie , Srod , Baldrick !

Now everything is OK !

Cheers
Pelluso
User
User
Posts: 23
Joined: Tue Mar 23, 2004 9:04 pm
Location: Brazil

Post 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
Post Reply