Gadget Blues Again - [FIXED]

Just starting out? Need help? Post your questions and find answers here.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Gadget Blues Again - [FIXED]

Post by kinglestat »

In the following code I have 3 bugs/problems I cannot find a solution for

1) enabling line after ;Disable/Enable following line will cause all buttons in container not to work
**FIXED


2) the image button added to toolbar is not visible though if you click it, it appears
**FIXED

3) to dissapear again when the about window comes on
**FIXED

I have done this code with help recieved from the forum, so any mistakes are mine

Code: Select all

Enumeration
   #MainWindow
   #MainImage
   #lv_image
   #Button1
   #Button2
   #Button3
   #MainTB
   #TBButton1
   #TBButton2
   #TBButton3
   #TBButton4
   #TBButton5
   #TBButton6
   #BTN2www
   #StaticTextFont
   #Container1
   #Container2
   #TestButton1
   #TestButton2
   #TestButton3
   #TextGadget1
   #TextGadget2
   #AboutWindow
EndEnumeration


#SBSizeMain       = 400
#SBSizeField      = 50
#SBClearDelay     = 9000

#CONTAINER_Y = 36
#CONTAINER_SIZEX = 400
#CONTAINER_SIZEY = 200


Macro   GadIMG ( GadNUM, ImgBrush )
   SetClassLong_ ( GadgetID ( GadNUM ), #GCL_HBRBACKGROUND, ImgBrush )
   InvalidateRect_ ( GadgetID ( GadNUM ), 0 ,1 )
EndMacro

Macro   SetStyle ( GadNUM )
  SetWindowLong_ ( GadgetID ( GadNUM ), #GWL_STYLE, GetWindowLong_ ( GadgetID ( GadNUM ), #GWL_STYLE) | #WS_CLIPSIBLINGS )
  SetWindowPos_ ( GadgetID ( GadNUM ), GadgetID ( GadNUM ), 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE )
EndMacro



Global      gWindowID.l
Global      gStatusBar.l
Global      gOldContainerProc1.l
Global      gOldContainerProc2.l
Global      ghBrushBack2.l


;/=============================================== 
;/ Procedure: SizeBackImage 
;/=============================================== 
Procedure.l SizeBackImage(hwnd, *rc.RECT) 
  Protected hdc, dc 
  If IsImage(#lv_image) 
    ResizeImage ( #lv_image, *rc\right-*rc\left, *rc\bottom-*rc\top) 
  Else 
    CreateImage ( #lv_image, *rc\right-*rc\left, *rc\bottom-*rc\top) 
  EndIf 
  hdc=StartDrawing ( ImageOutput ( #lv_image ) ) 
    dc = CreateCompatibleDC_(hdc) 
    If dc 
      SelectObject_(dc,ImageID ( #MainImage ) )
      StretchBlt_(hdc, 0,0,*rc\right-*rc\left, *rc\bottom-*rc\top,dc,0,0,ImageWidth ( #MainImage ),ImageHeight ( #MainImage ),#SRCCOPY) 
      DeleteDC_(dc) 
      result=1 
    Else 
      result=0 
    EndIf 
  StopDrawing() 
  ProcedureReturn result 
EndProcedure 



Procedure            ContainerProc1 ( hwnd.l, msg.l, wParam.l, lParam.l )

  Protected   gadRc.RECT, lvDc, bgDc
  
  ;...    
   If msg = #WM_ERASEBKGND
   
      GetClientRect_ ( hwnd, gadRc )
      SizeBackImage  ( hwnd, gadRc )
      
       lvDc = GetDC_ ( hwnd ) 
       ;...Get image DC 
       bgDc = StartDrawing(ImageOutput(#lv_image)) 
       BitBlt_ ( lvDc, 0, 0, gadRc\right - gadRc\left, gadRc\bottom - gadRc\top, bgDc, 0, 0, #SRCCOPY) 
      ;... Clean up 
       ReleaseDC_ ( hwnd, lvDc )
       StopDrawing() 
        
      ProcedureReturn 0
      
   EndIf
   
   ProcedureReturn CallWindowProc_ ( gOldContainerProc1, hwnd, msg, wParam, lParam )
   
EndProcedure 


Procedure            Open_MainWindow()

   Protected         hwnd.l
   Protected         winopts.l
   Protected         font.l
   
   winopts = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered
   hwnd = OpenWindow ( #MainWindow, 34, 25, 400, 340, "test", winopts )
   
   If Not hwnd
      ProcedureReturn #False
   EndIf 
   
   gWindowID = WindowID ( #MainWindow )
   gStatusBar = CreateStatusBar ( #MainWindow, gWindowID )
   
   If Not gStatusBar
      ProcedureReturn #False
   EndIf
   
   AddStatusBarField ( #SBSizeMain )
   AddStatusBarField ( #SBSizeField )
   AddStatusBarField ( #SBSizeField ) 
    
   If Not CreateGadgetList ( gWindowID ) 
      ProcedureReturn #False
   EndIf
   
   CatchImage ( #Button1, ?btn1 )
   CatchImage ( #Button2, ?btn2 )
   CatchImage ( #Button3, ?btn3 )
   CatchImage ( #MainImage, ?background )
   
   ButtonImageGadget ( #BTN2www, 250, 4, 100, 24, ImageID ( #Button3 ) )
   CreateTB ( #MainTB, hwnd, 24, 24, #TBpro_FLAT  | #TBpro_TRANSPARENT | #TBpro_BORDER )
   
      SetTBimage ( 0, 0, #TBpro_NORMAL )
      SetTBimage ( 0, 0, #TBpro_HOT )
      SetTBimage ( 0, 0, #TBpro_DISABLED )
      AddTBsysIcons ()
      
      AddTBbutton ( #TBButton1, #TBpro_CUT, #TBpro_BUTTON )
      AddTBbutton ( #TBButton2, #TBpro_PASTE, #TBpro_BUTTON )
      AddTBseparator ( 12 )
      AddTBbutton ( #TBButton3, #TBpro_DELETE, #TBpro_CheckBUTTON )
      AddTBbutton ( #TBButton4, #TBpro_FIND, #TBpro_CheckBUTTON )
      AddTBbutton ( #TBButton5, #TBpro_REPLACE, #TBpro_CheckBUTTON )
      AddTBseparator ( 12 ) 
      
   UpdateTB ()
      
      UseTB ( #MainTB )
      AddTBgadget ( GadgetID ( #BTN2www ), 250, 4 )   
      
   font = LoadFont ( #StaticTextFont, "Palatino", 11, #PB_Font_Bold )   
   ContainerGadget ( #Container1, 0, #CONTAINER_Y, #CONTAINER_SIZEX, #CONTAINER_SIZEY )
   
      ButtonGadget ( #TestButton1,  50, 80, 100, 50, "Test Button 1" )
      ButtonGadget ( #TestButton2, 250, 80, 100, 50, "Test Button 2" )
      StringGadget ( #TextGadget1, 50, 30, 200, 25, ""  )
      CloseGadgetList()
      
   gOldContainerProc1 = SetWindowLong_ ( GadgetID ( #Container1 ), #GWL_WNDPROC, @ContainerProc1() )   
   ProcedureReturn #True

EndProcedure

Procedure            Open_AboutWindow ()
   
   Protected         hwnd.l
   Protected         winopts.l
   Protected         font.l
   Protected         id.l
   
   winopts = #PB_Window_WindowCentered
   hwnd = OpenWindow ( #AboutWindow, 0, 0, 380, 200, "About - Test", winopts, gWindowID )
   
   If Not hwnd
      ProcedureReturn #False
   EndIf 
   
   id = WindowID ( #AboutWindow ) 
    
   If Not CreateGadgetList ( id ) 
      ProcedureReturn #False
   EndIf
   
   ghBrushBack2    = CreatePatternBrush_ ( ImageID ( #MainImage ) )
   
   font = LoadFont ( #StaticTextFont, "Garamond", 12, #PB_Font_Bold )
   ContainerGadget ( #Container2, 0, 0, 380, 200 )   
   
      ButtonGadget  ( #TestButton3,   40,  40, 95,  35, "Close" )
      StringGadget  ( #TextGAdget2,   40, 140,   300, 20, "" )
      CloseGadgetList()
      
   GadIMG ( #Container2, ghBrushBack2 )
      
   ProcedureReturn #True
   
EndProcedure


Procedure            Main ()
   
   Protected         id.l, idpos.l ,result.l
   Protected         EventID.l
   Protected         ButtonState.l
   Protected         nEvents.l
   
   If Open_MainWindow()
   
      Repeat
         
         EventID = WaitWindowEvent()

         If EventID = #PB_Event_Gadget
            nEvents = EventGadget()
            
            If nEvents = #TestButton3
              CloseWindow ( #AboutWindow )              
            ElseIf nEvents = #TestButton1 Or nEvents = #TestButton2
              Open_AboutWindow ()
            EndIf
            
         EndIf
         
      Until EventID = #PB_Event_CloseWindow
      
   EndIf

EndProcedure


Main()   
End
   
;- Data Section
DataSection

background:    IncludeBinary "back.bmp"
btn1:          IncludeBinary "buttona.BMP"
btn2:          IncludeBinary "buttonb.BMP"
btn3:          IncludeBinary "buttonc.BMP"


EndDataSection
cheers

KingLestat


**EDIT
Thanks to srod's suggestion and (again) from srod own posts I found a routine SizeBackImage which seems to do the job + some other of er...srods code again...modified the callback routine
Last edited by kinglestat on Sat Jul 14, 2007 8:51 pm, edited 1 time in total.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Hi,

I can't run your code because I no longer have the ToolBarPro library and all the missing images, but I do know that AddTBgadget () requires the handle of the gadget, not the gadget#.

So you need AddTBgadget (GadgetId(#BTN2www), 250, 4 ) etc.

I reckon this will solve 2) and 3).

**EDIT: you do realise that the image gadget and the container have exactly the same dimensions and coordinates? This is actually a trick used to render a gadget disabled without making it look disabled! This will undoubtedly explain 1). :)
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

based on your suggestion I tried the following

Code: Select all

ImageGadget ( #MainImage, 1, #CONTAINER_Y + 1, #CONTAINER_SIZEX - 2, #CONTAINER_SIZEY - 2, ImageID ( #MainImage ) )
Gadgets still seem disabled

I suspect its a question of Z-order, even though container is transparent. I'm actually using your (srod's) prior help for making the container transparent.

EDIT:
Re GadgetID() you where right and fixed problem 2 and 3 it seems thanks
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

But the fact that the image gadget and container still overlap will undoubtedly be the cause of this problem. If you wish to change the z-order then try SetWindowPos_().

On the other hand if all you want to do is display a background image in the container; then there are a couple of options:
  1. Remove the #WM_ERASEBKGND handler and the image gadget and set the container's background brush to one created with CreatePatternBrush_(ImageId(etc.)). Use SetClassLong_() to change the background brush.
  2. Alternatively, remove the image gadget. In the #WM_ERASEBKGND handler for the container, fill the Client Rectangle with a copy of the image. Use BitBlt_() or StretchBlt_() for this. Return zero from the handler.
Another option completely is to try placing the buttons inside the Image gadget. This might involve setting a few style bits and possibly the z-orders, but it might be worth considering.
I may look like a mule, but I'm not a complete ass.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

To make the buttons work, you could consider using #WS_CLIPSIBLINGS

Code: Select all

;{- Enumerations / DataSections
;{ Windows
Enumeration
  #Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
  #Image_0_Gadget0
  #Button_1_Gadget1
EndEnumeration
;}
;{ Images
Enumeration
  #Image_Image_0_Gadget0
EndEnumeration
;}
;{ Included Images
DataSection ;>
  Image_Image_0_Gadget0:
  ; IncludeBinary "C:\PureBasic400\Examples\Sources\Data\clouds.jpg"
  ;{Size = 5331 bytes
  Data.l $E0FFD8FF,$464A1000,$01004649,$48000102,$00004800,$4209EDFF,$746F6850,$6F68736F,$2E332070,$42380030,$ED034D49,$7365520A
  Data.l $74756C6F,$006E6F69,$10000000,$B4FF4700,$02000200,$B4FF4700,$02000200,$4D494238,$46180D04,$6C472058,$6C61626F,$67694C20
  Data.l $6E697468,$6E412067,$00656C67,$04000000,$78000000,$4D494238,$46121904,$6C472058,$6C61626F,$746C4120,$64757469,$00000065
  Data.l $00000400,$42381E00,$F3034D49,$6972500B,$4620746E,$7367616C,$09000000,$00000000,$00000000,$42380001,$0A044D49,$706F430E
  Data.l $67697279,$46207468,$0067616C,$01000000,$42380000,$10274D49,$70614A14,$73656E61,$72502065,$20746E69,$67616C46,$00000073
  Data.l $01000A00,$00000000,$02000000,$4D494238,$4317F503,$726F6C6F,$6C614820,$6E6F7466,$65532065,$6E697474,$00007367,$2F004800
  Data.l $01006666,$66666C00,$00000600,$01000000,$66662F00,$A1000100,$06009A99,$00000000,$32000100,$01000000,$00005A00,$00000600
  Data.l $01000000,$00003500,$2D000100,$06000000,$00000000,$42380100,$F8034D49,$6C6F4317,$5420726F,$736E6172,$20726566,$74746553
  Data.l $73676E69,$70000000,$FFFF0000,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$0000E803,$FFFF0000,$FFFFFFFF,$FFFFFFFF
  Data.l $FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$0000E803,$FFFF0000,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$0000E803,$FFFF0000
  Data.l $FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$0000E803,$4D494238,$47060804,$65646975,$00000073,$00001000,$00000100
  Data.l $00004002,$00004002,$42380000,$1E044D49,$4C52550D,$65766F20,$64697272,$00007365,$00000400,$42380000,$1A044D49,$696C5306
  Data.l $00736563,$6D000000,$06000000,$00000000,$00000000,$00010000,$00010000,$06000000,$6C006300,$75006F00,$73006400,$01000000
  Data.l $00000000,$00000000,$00000000,$00000000,$01000000,$00000000,$00000000,$00010000,$00010000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$42380000,$11044D49,$43434911,$746E5520,$65676761,$6C462064,$00006761
  Data.l $00010100,$4D494238,$4C171404,$72657961,$20444920,$656E6547,$6F746172,$61422072,$00006573,$00000400,$42380100,$0C044D49
  Data.l $77654E15,$6E695720,$73776F64,$75685420,$616E626D,$00006C69,$0000A105,$00000100,$00007000,$00007000,$00005001,$00000093
  Data.l $18008505,$D8FF0100,$1000E0FF,$4649464A,$01020100,$48004800,$EEFF0000,$64410E00,$0065626F,$00008064,$DBFF0100,$0C008400
  Data.l $09080808,$09090C08,$0A0B110C,$0F15110B,$150F0C0C,$15131318,$11181313,$0C0C0C0C,$0C110C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C
  Data.l $0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$010C0C0C,$0D0B0B0D,$0E100D0E,$0E14100E,$14140E0E,$0E0E0E0E,$0C0C1114,$110C0C0C,$0C0C0C11
  Data.l $110C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$1100C0FF,$00700008,$22010370,$01110200
  Data.l $FF011103,$000400DD,$01C4FF07,$0100003F,$01010105,$00010101,$00000000,$00030000,$05040201,$09080706,$00010B0A,$01010501
  Data.l $01010101,$00000000,$01000000,$04030200,$08070605,$100B0A09,$01040100,$02040203,$08060705,$330C0305,$11020001,$12210403
  Data.l $51410531,$71221361,$14063281,$42B1A191,$52152423,$343362C1,$43D18272,$53922507,$63F1E1F0,$A2163573,$442683B2,$45645493
  Data.l $3674A3C2,$E255D217,$84B3F265,$E375D3C3,$942746F3,$95B485A4,$F4E4D4C4,$D5C5B5A5,$6656F5E5,$A6968676,$E6D6C6B6,$574737F6
  Data.l $97877767,$D7C7B7A7,$0011F7E7,$02010202,$04030404,$07070605,$01350506,$03110200,$04123121,$71615141,$32051322,$A1149181
  Data.l $C12342B1,$33F0D152,$72E16224,$53439282,$34736315,$160625F1,$0783B2A2,$D2C23526,$A3549344,$55456417,$E2657436,$C384B3F2
  Data.l $F3E375D3,$85A49446,$D4C495B4,$B5A5F4E4,$F5E5D5C5,$86766656,$C6B6A696,$27F6E6D6,$67574737,$A7978777,$DAFFC7B7,$01030C00
  Data.l $03110200,$003F0011,$29A4DDD4,$EE35B235,$62E55698,$B71203A6,$361A40E4,$158F36D1,$020D443F,$486C2BB6,$F68BCAED,$DC8F02F2
  Data.l $7BD31625,$11C2F176,$6295E070,$51952DD1,$AA61A9FC,$C2839759,$27147C89,$258A0E3A,$822095E4,$41259B52,$DD4276D6,$29489BAA
  Data.l $1F642ADC,$449DD31D,$94004CF7,$34C53756,$9A0A53D0,$87953D4F,$753D211D,$12B13AA9,$50566614,$E9D0FF5F,$41251005,$B6CAB4C0
  Data.l $5D0500FF,$115B98FA,$59AB2D91,$3EE91EB6,$34364808,$11EC6D29,$4F5B4DD1,$553EAB60,$07225BEB,$D561B92A,$A625094D,$40E5EDE6
  Data.l $1EA84FAB,$0AC01C50,$A2B4329E,$D0210A70,$85705374,$534E0910,$6A87BC36,$28C932AC,$B588662D,$C91404D7,$B8559BD2,$7EB27694
  Data.l $B481156A,$15B0742B,$A5A57256,$ECE9D1FF,$35149D79,$7D44F73A,$44345366,$5604D7CA,$A721A68D,$130298BA,$7D510112,$08A58E90
  Data.l $03CA1AAC,$F78EDECF,$83682002,$480A93E9,$3BE6AAED,$B640793C,$C2C055BD,$D7346387,$55CBF894,$28397D34,$B042A48D,$B2A2BBDA
  Data.l $29394E99,$93AED456,$AB3B8D3A,$0010A44D,$9A3E0656,$884755A3,$092A4B51,$4C92B26B,$6DCDCA0E,$3F2A3FDA,$144D23A2,$F5FE595F
  Data.l $82C4C901,$EDD2FF6D,$AA705F1D,$40AB065C,$51D931C0,$A55503C9,$05D8EA8C,$A58565A5,$A90EDC0C,$548523AF,$5D050338,$DB0B018C
  Data.l $51EE90B5,$A9826DCC,$2B1A6857,$4C74B20D,$06924A9C,$5527E57C,$23A34EDD,$764CA9CC,$2D84B24C,$8C6155AB,$10050F1A,$07AA4775
  Data.l $C8D9243F,$74AE20A1,$C2046344,$16921D69,$0654DE01,$0A6C35CA,$AA0F0A81,$A355A504,$B95DA6E0,$752BA847,$EDD3FF7F,$AEEAEE5E
  Data.l $6E230441,$5579B005,$4E2B7FAE,$68C05603,$3D01D0DE,$72A77BD6,$E96490BD,$9DE6A6AA,$022DFECA,$5885C9F0,$5577C4AD,$D50848C3
  Data.l $5229258E,$28837E4B,$88069096,$AC09710C,$C3AFC2B0,$6D2E6D65,$5BD5E88E,$A0C2933A,$3BD535EB,$8EE3846F,$F5D469C2,$064A3EC1
  Data.l $872A4FE0,$94D334DA,$EEC1A485,$9DA2EC99,$B93BED1A,$926D5AD1,$E2546621,$B2E731AD,$0F41708E,$5FE9D4FF,$7540F169,$92988287
  Data.l $79441E54,$B4C5B8AD,$A0803C18,$D2DD8D40,$93B79073,$A50498C2,$A2EB0468,$AB700028,$673095B4,$9B829442,$B0A6742D,$6C513482
  Data.l $E15E148E,$ADA3EEA8,$34CF8A54,$44383A37,$C2329470,$06438AA6,$58E5F7BC,$5B505DAB,$36D6A354,$94AA84E8,$B5A3A4DB,$C7AA42FB
  Data.l $AB5EA600,$905636CA,$D5FF00FF,$058075DC,$A94CF65D,$84EC7738,$D095751A,$60DB0044,$93D624E7,$51CD72C2,$264FD858,$146B5682
  Data.l $124801C0,$A63A8F02,$87194A12,$056C94FC,$07A99C36,$6543C8CC,$1148D521,$4A6827DD,$6A38C587,$940082A4,$1A4FB0ED,$8846E821
  Data.l $2E619064,$BC64531B,$1DBC3605,$3A1FA84A,$AA413323,$FF143406,$00D9FF00,$4D494238,$561A2104,$69737265,$63206E6F,$61706D6F
  Data.l $69626974,$7974696C,$666E6920,$0000006F,$00005500,$00010100,$000F0000,$00640041,$0062006F,$00200065,$00680050,$0074006F
  Data.l $0073006F,$006F0068,$00000070,$00410013,$006F0064,$00650062,$00500020,$006F0068,$006F0074,$00680073,$0070006F,$00360020
  Data.l $0030002E,$00010000,$4D494238,$4A0C0604,$20474550,$6C617551,$00797469,$07000000,$00000100,$00010100,$0E00EEFF,$626F6441
  Data.l $80640065,$01000000,$8400DBFF,$08080C00,$0C080908,$110C0909,$110B0A0B,$0C0C0F15,$1318150F,$13131513,$0C0C1118,$0C0C0C0C
  Data.l $0C0C0C11,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0B0D010C,$0D0E0D0B,$100E0E10,$0E0E0E14,$0E0E1414
  Data.l $11140E0E,$0C0C0C0C,$0C11110C,$0C0C0C0C,$0C0C110C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$0C0C0C0C,$C0FF0C0C
  Data.l $01081100,$03000100,$02002201,$11030111,$00DDFF01,$FF100004,$003F01C4,$01050100,$01010101,$00000001,$00000000,$02010003
  Data.l $07060504,$0B0A0908,$05010001,$01010101,$00000101,$00000000,$02000100,$06050403,$0A090807,$0100100B,$02030104,$07050204
  Data.l $03050806,$0001330C,$04031102,$05311221,$13615141,$32817122,$A1911406,$242342B1,$62C15215,$82723433,$250743D1,$E1F05392
  Data.l $357363F1,$83B2A216,$54934426,$A3C24564,$D2173674,$F265E255,$D3C384B3,$46F3E375,$85A49427,$D4C495B4,$B5A5F4E4,$F5E5D5C5
  Data.l $86766656,$C6B6A696,$37F6E6D6,$77675747,$B7A79787,$F7E7D7C7,$02020011,$04040201,$06050403,$05060707,$02000135,$31210311
  Data.l $51410412,$13227161,$91813205,$42B1A114,$D152C123,$622433F0,$928272E1,$63155343,$25F13473,$B2A21606,$35260783,$9344D2C2
  Data.l $6417A354,$74365545,$B3F2E265,$75D3C384,$9446F3E3,$95B485A4,$F4E4D4C4,$D5C5B5A5,$6656F5E5,$A6968676,$E6D6C6B6,$473727F6
  Data.l $87776757,$C7B7A797,$0C00DAFF,$02000103,$00110311,$69D5003F,$4A199548,$B54D4357,$2A0129C4,$01444920,$A965A402,$D936CA06
  Data.l $1287184E,$8AD30A91,$4B3118E1,$424A1C6A,$515AA25A,$85E0A4B6,$2A890AA9,$14286C4F,$20E5A5F0,$466E29A3,$92A8C894,$52C9E496
  Data.l $44A59497,$94344AA8,$510994BB,$D2284D2E,$44CA9429,$97A88CC2,$296549A3,$722A184A,$7498298D,$BDA13225,$94522838,$33556754
  Data.l $850881AA,$6B510232,$6084150A,$7DA62299,$A6440A94,$FF213425,$3C49D3D0,$A1ABE114,$45ECDAB6,$8416950D,$55E4A866,$BD14636A
  Data.l $89004634,$5A32A212,$59248650,$31619B08,$D1A69532,$71448142,$78AA3384,$27F44248,$80100E2B,$88542CF5,$531E29A5,$E1A41229
  Data.l $6EA824CA,$23298D82,$44B9A19C,$022253BA,$29A31299,$4AA3408A,$80422967,$A5A4402A,$82149E00,$14C61474,$80144A80,$022E9540
  Data.l $52C0545B,$626899D8,$4C42A2D6,$84092062,$154494A8,$28F61112,$2D0A2438,$DADAD1FF,$0C462BA4,$DF16B64F,$A70F6D13,$48D16D0A
  Data.l $95681785,$142BADDA,$4F0E4181,$528434BD,$408AAA53,$374250A4,$822BCA21,$0B4FB413,$030A1B83,$DC50DCD4,$95918AA5,$95486112
  Data.l $04520907,$2D492EB0,$EA898EA9,$25955151,$4A948A12,$9872A98C,$F5B69484,$2441BD26,$92834969,$9E1C84DC,$6927A550,$B0AB1044
  Data.l $E42807A3,$36159414,$0A888220,$144C0861,$1A4441D0,$E052C8A8,$0AA55AA4,$A285B241,$EAD2FFDF,$119EC458,$D57A5078,$9C68B305
  Data.l $5C11DE10,$C253ED86,$91203542,$524EC009,$A4E08481,$4A496842,$A2044F28,$A000A114,$814A73D5,$01C2C30A,$11A54453,$226C9B12
  Data.l $D43E21A6,$AB08C185,$62196A0F,$D4082970,$36540B51,$E196DAA7,$3421A734,$512EA622,$A9487252,$6A403A41,$584A02A4,$6D29A768
  Data.l $A4290D52,$2B0A9BA9,$AA461342,$4A8A02C3,$C08AC064,$6C8A6E90,$9256120A,$6A8C08B8,$6AACA841,$FF8B8A64,$869CEBD3,$2F428954
  Data.l $4236A05A,$C69DA09E,$AA842753,$52A22125,$75292997,$6D299C12,$44614C49,$890D42A3,$54070604,$9942C422,$6A871248,$0245D462
  Data.l $082CED53,$6C172150,$054E2DA6,$3204774D,$90A1F68E,$0A2C05A4,$42214481,$08538113,$AA3D0548,$98DAA841,$7F028800,$8409384D
  Data.l $D0A450A1,$6694AD9D,$14953431,$A5D58861,$4CAD49B5,$404AD226,$8886D854,$2928A2D0,$2A34AC98,$A8C008ED,$D4FFB1A4,$27E41EEA
  Data.l $0795BF29,$82B6882D,$A4A448C1,$0A614802,$48422940,$4C01965A,$24A9C428,$5E10A254,$48194A88,$44212228,$E505BDA2,$62C1154B
  Data.l $53A404A2,$014A39B5,$E1E99428,$507B2125,$04A7155C,$95F8D422,$0613025A,$1AA416A2,$21B6699D,$9BA8418A,$C940ED53,$30B58C16
  Data.l $51361CAD,$89374105,$23646B48,$53ED1300,$51095363,$EDA90462,$15440D53,$0A9261CA,$5A41D410,$E114AA20,$B104CD30,$88844B01
  Data.l $87981285,$8BEAD5FF,$2D5AA150,$41B5D850,$DBD7826C,$9B6A6C0A,$75C2A1D8,$28D9AEDA,$17D3DB94,$5BA64AA5,$6E281793,$499D5E4C
  Data.l $3BCA45A6,$EED3CBD0,$B14A9546,$A5548D0C,$DB29193B,$A9656427,$D618216D,$43E2129A,$92C21300,$A1282D74,$A11CC141,$A2C02991
  Data.l $0AA9C4D0,$4961C3D4,$D8A6C4A9,$A906A906,$B482A835,$011624C3,$36B58288,$98561831,$D383A266,$7A23D64E,$BC69C569,$A3C66248
  Data.l $319CB0B1,$A4140548,$A058ACB4,$300A8F58,$9B0BA585,$92557028,$05110B14,$EDD6FF01,$2320140B,$F8572D26,$E181169B,$C41EC105
  Data.l $52341517,$E786E880,$B9A0B8A9,$F557024C,$73402F12,$3FB530A1,$93CB2985,$3BBD8502,$4CAA544A,$13422B02,$0A532B4A,$A290288B
  Data.l $4A539E58,$52EC1862,$08384901,$6281ADDA,$6863C51E,$AA855A4C,$C6A496D0,$0D526DA2,$6331B54E,$04488011,$9430E5ED,$2802BB12
  Data.l $63119809,$25281145,$0C53C986,$6D3A0152,$A6D0D4AA,$94B328D6,$41694240,$11DBC456,$B548051B,$A06D8933,$58B1A1D8,$E1F486D8
  Data.l $00FF8224,$62EED7FF,$05F54E12,$811D9975,$562BB456,$34C55A15,$88A50617,$57B1474F,$5E31ABB0,$EA3EC486,$2A98426F,$11CDA060
  Data.l $81C821A8,$D8A210C9,$55391005,$9443D16B,$E6292A46,$946B4252,$499536E5,$1D22AA19,$146A1065,$025E6965,$4A4C265A,$9CEA5C4A
  Data.l $52704A28,$09363553,$74236251,$5A292A4D,$A541E114,$0565544E,$A58C4A49,$808420B8,$84EF20A9,$55E1D083,$77511836,$267ACC2A
  Data.l $82A21CF5,$04CAB919,$96A4404A,$D0FF7FC8,$099549EE,$7C954049,$EAA77006,$36026B15,$920A2BE4,$ABD86A09,$097A5A39,$F68A5801
  Data.l $7340F4B3,$DC55EC91,$434C45AC,$501210A1,$529E1891,$E4301590,$8C02A430,$916B2685,$A271559A,$82644A23,$62452D1B,$C5B04A03
  Data.l $0AB99004,$82F01405,$165084F2,$97A1B794,$C29FDE26,$A2C74C9A,$914355EF,$51315018,$6651D66C,$133A7615,$2B26549B,$9AD25D4A
  Data.l $8B89C550,$22D3A4D1,$41F820F5,$D22891DE,$442DB0A9,$5140D563,$6513ED98,$7AD01614,$D443D05B,$B5C247E5,$25EDD1FF,$A930E941
  Data.l $D9D1421D,$C50A8DB0,$E282E837,$39518AA4,$DA19E501,$E2A9F6AA,$0E282F94,$6E288E08,$532CC553,$602A1885,$0AB29427,$12A7A840
  Data.l $8D92A49A,$2220A85E,$362447B1,$6060D418,$0AA60220,$A5148484,$89296EE8,$01D27343,$1295C454,$1DE5624A,$2025E0C9,$56B9B528
  Data.l $88E42095,$4D6E6D51,$717A03B9,$130A6F62,$805E4CEF,$292C4C6C,$B138A570,$EEABA83F,$8C946152,$4661D954,$519A5561,$0B725458
  Data.l $230AB069,$960A805C,$210819E5,$A6EBD2FF,$4B10F512,$D68A0BD4,$7B256CE1,$05EA09E5,$A797A8FA,$8B012E08,$CA38208C,$8550B52B
  Data.l $B5845234,$2A47CD0D,$AAE0A925,$6DA906D0,$1B498844,$2085B04D,$831420D5,$B4162550,$0AA3D622,$662A4C6C,$775420D5,$99620A24
  Data.l $54842714,$1114A237,$4C612294,$20553BA8,$7D7A5B50,$D30911EA,$24F72CA9,$CA25081F,$0A97D221,$20A51B9B,$530E4175,$49112205
  Data.l $82585166,$CA2866D4,$0322668A,$51444C08,$44AD1414,$9B280C08,$435A08D3,$25E9D3FF,$A0D29440,$D5A6DA4A,$A737542E,$C10931E5
  Data.l $1437944A,$014F31A5,$0A4E492C,$09DD5189,$516EA6D4,$14482E51,$515A4969,$A7200801,$54214D0E,$E4863299,$92522881,$1084A9B4
  Data.l $4A531261,$26506F19,$20052A52,$05CAC512,$A4329448,$49545A0A,$A7987029,$618A8325,$845199A2,$230A2EF5,$1505104A,$3BA93481
  Data.l $511B0251,$9A504425,$CD8088B2,$94504111,$17C96116,$4A694A28,$D4FF4F95,$F024D5DD,$316DDC92,$2225263A,$25204A86,$9392A867
  Data.l $00A91C8A,$92518952,$708A8A93,$84136409,$A90838C1,$52889292,$4581424D,$B0296008,$70169526,$3FE10990,$4C628A09,$76271728
  Data.l $E08407AA,$A1291614,$E5144829,$22342130,$91DA0825,$A26C9010,$951A4CED,$986A88A5,$7802A410,$825A9440,$4B015020,$61A6D284
  Data.l $5BE861CA,$42988293,$B7292129,$4A909228,$D5FF4F93,$CAC594DD,$CB05CA05,$BBB64574,$A25CA09C,$90CA28E7,$512E4A45,$38992225
  Data.l $85264925,$2CE58436,$01539002,$94303548,$8527C05A,$0911A93D,$292086B6,$5CCA284C,$7220A9A6,$C1692853,$A1C89246,$0B145294
  Data.l $92480552,$27132252,$2095965A,$4A4A139A,$C221D967,$5230F51E,$31E132A5,$39E46272,$491520D5,$50E6D483,$C8312937,$2921A918
  Data.l $4D09D483,$28A95229,$16D48832,$21502095,$D6D6FF45,$27CA4421,$A00B2F2A,$DC85B605,$94C814A4,$53EB8480,$54631402,$48350255
  Data.l $4C013115,$0422C004,$38E14A89,$9A809329,$99987286,$4B354549,$94241A27,$704921A7,$49892990,$4829F72C,$28A51084,$D4538A10
  Data.l $2850C914,$3125B184,$4A4E2949,$4A2829E0,$9129C97D,$40E54443,$CA988284,$94525470,$E89433E5,$50DDA672,$21A24652,$610AA480
  Data.b $43,$FF,$D9
  ;}
EndDataSection ;<
;}
;{ Image Plugins
UseJPEGImageDecoder()
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 450, 200, 400, 400, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    If CreateGadgetList(WindowID(#Window_0))
      ImageGadget(#Image_0_Gadget0, 69, 10, 260, 260, CatchImage(#Image_Image_0_Gadget0, ?Image_Image_0_Gadget0), #PB_Image_Border)
      ButtonGadget(#Button_1_Gadget1, 146, 112, 115, 47, "Gadget_1")
      ; /////////////////////
      SetWindowLong_(GadgetID(#Image_0_Gadget0), #GWL_STYLE, GetWindowLong_(GadgetID(#Image_0_Gadget0), #GWL_STYLE) | #WS_CLIPSIBLINGS)
      SetWindowPos_(GadgetID(#Image_0_Gadget0), GadgetID(#Button_1_Gadget1), 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
      ; /////////////////////
    EndIf
  EndIf
EndProcedure

OpenWindow_Window_0()

;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
    ; ///////////////////
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = #Image_0_Gadget0
      ElseIf EventGadget = #Button_1_Gadget1
        MessageRequester("!", "Clicked button")
      EndIf
      ; ////////////////////////
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = #Window_0
        CloseWindow(#Window_0)
        Break
      EndIf
  EndSelect
ForEver
;
;}
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

To make the buttons work, you could consider using #WS_CLIPSIBLINGS
Aye, that was one of the styles I was thinking about! :)
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

thanks for example
but you see I dont have a problem when not using the containergadget.
I use the container cadgets to easily flip "pages" whilst preserving same background. I did not expect it would be so complicated
:roll:

Is there a simpler way to do this?
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

and
how do you do those data stuff from a file? Is there an automatic way to do this?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

kinglestat wrote:and
how do you do those data stuff from a file? Is there an automatic way to do this?
Just write a small utility which dumps a file to a PB program etc.

I just happen to have one lying around the floor!

Code: Select all

;This small utility creates a data section in raw binary format out of an external file.
;Useful for embedding small images directly within a source program etc,

;No error checking.

#linelength=40

inputfile$="back.ico"
outputfile$="data.pbi"

;Main program.
If CreateFile(1, outputfile$)
  WriteStringN(1, ";"+inputfile$)
  WriteStringN(1,"")
  WriteStringN(1,"DataSection")
  ReadFile(2, inputfile$)
  line$="  Data.b "
  While Eof(2) = 0
    count+1
    byte.c=ReadByte(2)
    line$+Str(byte)
    If count=#linelength
      WriteStringN(1, line$)
      line$="  Data.b "
      count=0
    Else
      line$+", "
    EndIf
  Wend
  If line$<> "  Data.b "
    WriteStringN(1, Left(line$, Len(line$)-2))
  EndIf
  CloseFile(2)
  WriteStringN(1,"EndDataSection")
  CloseFile(1)
Else
  MessageRequester("Error!", "Problem creating output file!")
EndIf
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

clever
thanks srod once again
I guess I have to upgrade from a couple of beers to a couple of champagne bottles next time I'm in England.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I only drink out of barrels these days! :wink:
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

a barrel it is then :!:
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

sRod,
If that is a sample of whats just laying around on the floor... I would LOVE to see whats tossed haphazardly on your desk!

Great tool! Thanks! 8)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

moot point rook
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Rook Zimbabwe wrote:sRod,
If that is a sample of whats just laying around on the floor... I would LOVE to see whats tossed haphazardly on your desk!

Great tool! Thanks! 8)
Trust me, you really don't want to know what's lying on top of and underneath my desk! I really should get a cleaner I guess!

:)
I may look like a mule, but I'm not a complete ass.
Post Reply