Stephan Sonneborn | allô zusammen,
après que je toujours wieder la fois pour Quellcodes avec Toolbars et TabControls gesucht habe, habe je maintenant la fois quoi zusammengestellt, wohin qui wichtigsten Punkte zusammengefasst sommes.
Bedanken voudrais je mich chez Thomas Bois, Andreas Miethe, Rolf Koch et David Strutz pour diverse Quellcode-Schnippsel. KompilierenMarqueSéparationToolbarPlus in XPROFAN
Autor: Stephan Sonneborn
Zusammengestellt aus Quelltexten von Thomas Hölzer, Andreas Miethe, Rolf Koch und David Strutz
************************************************************************************************
* Header-Dateien laden *
************************************************************************************************
$H WINDOWS.PH
$H COMMCTRL.PH
+----------------------------------------------------------------------------------------------+
SET(ErrorLevel, 0) fertiges Programm: 0!
SET(FASTMODE, 0) fertiges Programm: 0!
SET(TRUECOLOR, 1) fertiges Programm: 1!
SET(AUTOPAINT, 2) fertiges Programm: 2!
SET(MESSAGEMODE, 1)fertiges Programm: 1!
DECIMALS 8
************************************************************************************************
* Definitionen *
************************************************************************************************
DEF HiWord(1) Div&(&(1),$10000)
DEF LoWord(1) And(&(1),$FFFF)
DEF MakeLong(2)Or(&(1),Mul(&(2),$10000))
DEF SetWindowLong(3) !USER32,SetWindowLongA
DEF GetWindowLong(2) !USER32,GetWindowLongA
DEF ImageList_AddIcon(2) !COMCTL32,ImageList_AddIcon
DEF ImageList_Create(5) !COMCTL32,ImageList_Create
DEF LoadIcon(2) !USER32,LoadIconA
DEF EnableTBButton(3) SendMessage(&(1),$0401,-&(2),&(3))
DEF ToolbarResize(1) SENDMESSAGE(@&(1),1057,0,0)
+----------------------------------------------------------------------------------------------+
************************************************************************************************
* Globale Variablen *
************************************************************************************************
DECLARE DLL$,DLL&, ToolbarText$[4,2]
DECLARE ToolBar&, ToolTip&, PushedToolButton%
+----------------------------------------------------------------------------------------------+
************************************************************************************************
* Usermessages *
************************************************************************************************
USERMESSAGES 16 Programm beenden
+----------------------------------------------------------------------------------------------+
************************************************************************************************
* Wertzuweisungen *
************************************************************************************************
WHILELOOP 0,4,1
ToolbarText$[&LOOP,1] = Button + STR$(&LOOP)
ToolbarText$[&LOOP,2] = Button-Tooltip + STR$(&LOOP)
WEND
+----------------------------------------------------------------------------------------------+
************************************************************************************************
* Toolbarbutton anlegen *
************************************************************************************************
PROC AddToolBarButton
PARAMETERS TB_Handle&, Button_Handle%,
Button_State%, Button_Style%, Bitmap_IDX%, ToolButtonText$, ToolTipText$
DECLARE ButtonStruct#, ButtonText#
DECLARE ToolTipStruct#, ToolTipText#
DECLARE String_IDX%
+----------------------------------------------------------------------------------------------+
DIM Buttonstruct# , 20
DIM ButtonText# , LEN(ToolButtonText$)+1
DIM ToolTipStruct#, 40
DIM ToolTipText# , LEN(ToolTipText$)+1
+----------------------------------------------------------------------------------------------+
CASE Button_Handle% > 0: Button_Handle% = (-1) * Button_Handle%
+----------------------------------------------------------------------------------------------+
Tooltip anlegen
+----------------------------------------------------------------------------------------------+
STRING ToolTipText#, 0 = ToolTipText$
LONG ToolTipStruct#, 0 = 40
LONG ToolTipStruct#, 4 = 0
LONG ToolTipStruct#, 8 = TB_Handle&
LONG ToolTipStruct#,12 = Button_Handle%
LONG ToolTipStruct#,36 = ToolTipText#
SENDMESSAGE(SENDMESSAGE(TB_Handle&,1059,0,0) ,1028, 0, ToolTipStruct#)
+----------------------------------------------------------------------------------------------+
Toolbar-Button anlegen
+----------------------------------------------------------------------------------------------+
STRING ButtonText#, 0 = ToolButtonText$
String_IDX% = SENDMESSAGE(TB_Handle&,1052,0,MAKELONG(ButtonText#,0))
LONG ButtonStruct#, 0 = Bitmap_Idx%
LONG ButtonStruct#, 4 = Button_Handle%
BYTE ButtonStruct#, 8 = Button_State%
BYTE ButtonStruct#, 9 = Button_Style%+4
LONG ButtonStruct#,16 = String_Idx%
SENDMESSAGE(TB_Handle&, 1044, 1, ButtonStruct#)
SENDMESSAGE(TB_Handle&, 1025, Button_Handle%, 1)
+----------------------------------------------------------------------------------------------+
DISPOSE ButtonStruct#
DISPOSE ButtonText#
DISPOSE ToolTipText#
DISPOSE ToolTipStruct#
+----------------------------------------------------------------------------------------------+
ENDPROC
************************************************************************************************
************************************************************************************************
* Separator für Toolbar anlegen *
************************************************************************************************
PROC AddToolBarSeparator
PARAMETERS TB_Handle&
AddToolbarButton TB_Handle&, 0, 0, 1, -1, ,
ENDPROC
************************************************************************************************
************************************************************************************************
* ToolbarButton zurücksetzen *
************************************************************************************************
PROC ReleaseToolBarButton
PARAMETERS TB_Handle&, Button_Handle%
+----------------------------------------------------------------------------------------------+
CASE Button_Handle% > 0: Button_Handle% = (-1) * Button_Handle%
+----------------------------------------------------------------------------------------------+
SENDMESSAGE(TB_Handle&, 1041, Button_Handle%, MAKELONG(4,0))
ENDPROC
************************************************************************************************
************************************************************************************************
* Toolbar generieren *
************************************************************************************************
PROC Create_ToolBar
PARAMETERS ImageFile$, IconWidth%, IconGroupname$, Flat%
DECLARE IconText#, IconsInFile%
DECLARE ImageList&
DECLARE DLL&
+----------------------------------------------------------------------------------------------+
+----------------------------------------------------------------------------------------------+
Imagelist anlegen
+----------------------------------------------------------------------------------------------+
DLL& = VAL(ImageFile$)
IF DLL&
DIM IconText# , LEN(IconGroupname$) + 1
STRING IconText#, 0 = IconGroupName$
ImageList& = ~ImageList_LoadImage(DLL&, IconText#, 32, 16, -1, 0, -32)
ELSE
DIM IconText#, 5
DLL& = USEDLL(ImageFile$)
ImageList& = ~ImageList_Create(IconWidth%, IconWidth%, 273, 64, 64) Imagelist erzeugen, 64 Icons
IconsInFile% = IconCount(ImageFile$)
WHILELOOP 0, IconsInFile%, 1
STRING IconText#, 0 = # + STR$(&LOOP)
ImageList_AddIcon(ImageList&, ~LoadIcon(DLL&, IconText#))
WEND
FREEDLL (DLL&)
ENDIF
DISPOSE IconText#
+----------------------------------------------------------------------------------------------+
+----------------------------------------------------------------------------------------------+
Toolbar inkl. Tooltip erzeugen:
+----------------------------------------------------------------------------------------------+
ToolBar& = CONTROL(ToolbarWindow32 ,,$54002201,0,0,0,0,%HWND,1001,%HINSTANCE,0)Toolbar
ToolTip& = CONTROL(tooltips_class32,,$D0000000,0,0,0,0,%HWND, 0,%HINSTANCE,0)Tooltip fuer Toolbar
CASE Flat%: SetWindowLong(ToolBar&,-16,OR(GetWindowLong(ToolBar&,-16),2048)) Flat-Toolbar
SENDMESSAGE(Toolbar&,1054, 20, 0) TB_ButtonStructSize
SENDMESSAGE(Toolbar&,1055, 0, MakeLong(IconWidth%, IconWidth%)) Buttonsize
SENDMESSAGE(Toolbar&,1060, ToolTip&, 0) Tooltip anbinden
SENDMESSAGE(Toolbar&,1071, 0, 0) ToolbarIndent
SENDMESSAGE(ToolBar&,1072, 0, ImageList&) Imagelist zuweisen
+----------------------------------------------------------------------------------------------+
ENDPROC
************************************************************************************************
************************************************************************************************
* Dialogfenster mit Tabcontrol *
************************************************************************************************
PROC Dialog
DECLARE Handle&
DECLARE TabControl&
DECLARE TabPage&[4]
DECLARE DlgButton&[3]
DECLARE Button&[4]
DECLARE Checkbox&[4]
DECLARE Edit&[4]
DECLARE ChoiceBox&[4]
DECLARE Groupbox&[4]
DECLARE DialogExit%, LastTab&
DECLARE ButtonClick%
-----------------------------------------------------------------------------------------------
Dialogfenster anzeigen
-----------------------------------------------------------------------------------------------
Handle& = CREATE(DIALOG, %HWND, Testdialog,100,100,515,445)
SETWINDOWPOS Handle& = (%MAXX-515)/2,(%MAXY-445)/2-515,445;0
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
PageControl
-----------------------------------------------------------------------------------------------
SETDIALOGFONT 0
TabControl& = CREATE(TABCTRL,Handle&,TabControl1,005,005,500,375)
WHILELOOP 4
CASE &LOOP > 1: INSERTTAB(TabControl&, &LOOP-1, TabControl+STR$(INT(&LOOP)))
TabPage&[&LOOP] = CONTROL(DIALOG,, $40081003,2,25,WIDTH(TabControl&)-5, HEIGHT(TabControl&)-29,TabControl&,0,%HINSTANCE)
SHOWWINDOW(TabPage&[&LOOP],0)
WEND
LastTab& = TabPage&[1]
SETDIALOGFONT 1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
PageControlButtons
-----------------------------------------------------------------------------------------------
DlgButton&[1] = CREATE(BUTTON , Handle& , OK , 430, 390, 075, 025)
DlgButton&[2] = CREATE(BUTTON , Handle& , Abbrechen , 350, 390, 075, 025)
DlgButton&[3] = CREATE(BUTTON , Handle& , Hilfe , 005, 390, 075, 025)
Button&[1] = CREATE(BUTTON , TabPage&[1], Button 1 , 020, 040, 075, 025)
Button&[2] = CREATE(BUTTON , TabPage&[2], Button 2 , 020, 040, 075, 025)
Button&[3] = CREATE(BUTTON , TabPage&[3], Button 3 , 020, 040, 075, 025)
Button&[4] = CREATE(BUTTON , TabPage&[4], Button 4 , 020, 040, 075, 025)
CheckBox&[1] = CREATE(CHECKBOX, TabPage&[1], Ein/Aus , 020, 070, 100, 025)
CheckBox&[2] = CREATE(CHECKBOX, TabPage&[2], Ein/Aus , 020, 070, 100, 025)
CheckBox&[3] = CREATE(CHECKBOX, TabPage&[3], Ein/Aus , 020, 070, 100, 025)
CheckBox&[4] = CREATE(CHECKBOX, TabPage&[4], Ein/Aus , 020, 070, 100, 025)
Edit&[1] = CREATE(EDIT , TabPage&[1], Edit 1 , 150, 040, 075, 025)
Edit&[2] = CREATE(EDIT , TabPage&[2], Edit 2 , 150, 040, 075, 025)
Edit&[3] = CREATE(EDIT , TabPage&[3], Edit 3 , 150, 040, 075, 025)
Edit&[4] = CREATE(EDIT , TabPage&[4], Edit 4 , 150, 040, 075, 025)
ChoiceBox&[1] = CREATE(CHOICEBOX,TabPage&[1], , 150, 070, 075, 075)
ChoiceBox&[2] = CREATE(CHOICEBOX,TabPage&[2], , 150, 070, 075, 075)
ChoiceBox&[3] = CREATE(CHOICEBOX,TabPage&[3], , 150, 070, 075, 075)
ChoiceBox&[4] = CREATE(CHOICEBOX,TabPage&[4], , 150, 070, 075, 075)
Groupbox&[1] = CREATE(GROUPBOX, TabPage&[1], Groupbox 1, 010, 010, 225, 100)
Groupbox&[2] = CREATE(GROUPBOX, TabPage&[2], Groupbox 2, 010, 010, 225, 100)
Groupbox&[3] = CREATE(GROUPBOX, TabPage&[3], Groupbox 3, 010, 010, 225, 100)
Groupbox&[4] = CREATE(GROUPBOX, TabPage&[4], Groupbox 4, 010, 010, 225, 100)
WHILELOOP 4
SETCHECK Checkbox&[&LOOP], 1
ADDCHOICE(Choicebox&[1], Text +STR$(&LOOP))
ADDCHOICE(Choicebox&[2], Text +STR$(&LOOP))
ADDCHOICE(Choicebox&[3], Text +STR$(&LOOP))
ADDCHOICE(Choicebox&[4], Text +STR$(&LOOP))
WEND
SHOWWINDOW(LastTab&,1)
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
Ereignishandler
-----------------------------------------------------------------------------------------------
WHILENOT DialogExit%
WAITINPUT
WHILELOOP 4
ENABLEWINDOW Button&[&LOOP] , GETCHECK(Checkbox&[&LOOP])
ENABLEWINDOW Edit&[&LOOP] , GETCHECK(Checkbox&[&LOOP])
ENABLEWINDOW ChoiceBox&[&LOOP], GETCHECK(Checkbox&[&LOOP])
WEND
IF GETFOCUS (DlgButton&[1])
ButtonClick% = %LASTMESSAGE
IF (ButtonClick% > 306) AND (ButtonClick% < 310) Editfeld o.ä. war angewählt -> Reaktion des Buttons erst beim Loslassen
WAITINPUT
CASENOT GETFOCUS (DlgButton&[1]): ButtonClick% = 0
ENDIF
IF ButtonClick%
MESSAGEBOX( OK gewählt!, Testdialog,64)
DialogExit% = 1
ENDIF
ELSEIF GETFOCUS (DlgButton&[2])
ButtonClick% = %LASTMESSAGE
IF (ButtonClick% > 306) AND (ButtonClick% < 310) Editfeld o.ä. war angewählt -> Reaktion des Buttons erst beim Loslassen
WAITINPUT
CASENOT GETFOCUS (DlgButton&[2]): ButtonClick% = 0
ENDIF
IF ButtonClick%
MESSAGEBOX( Abbrechen gewählt!, Testdialog,64)
DialogExit% = 1
ENDIF
ELSEIF GETFOCUS (DlgButton&[3])
ButtonClick% = %LASTMESSAGE
IF (ButtonClick% > 306) AND (ButtonClick% < 310) Editfeld o.ä. war angewählt -> Reaktion des Buttons erst beim Loslassen
WAITINPUT
CASENOT GETFOCUS (DlgButton&[3]): ButtonClick% = 0
ENDIF
IF ButtonClick%
MESSAGEBOX( Hilfe gewählt!, Testdialog,64)
ENDIF
ELSEIF GETFOCUS (Button&[1])
MESSAGEBOX( Button 1 gewählt!, Testdialog,64)
SETFOCUS(TabControl&)
ELSEIF GETFOCUS (Button&[2])
MESSAGEBOX( Button 2 gewählt!, Testdialog,64)
SETFOCUS(TabControl&)
ELSEIF GETFOCUS (Button&[3])
MESSAGEBOX( Button 3 gewählt!, Testdialog,64)
SETFOCUS(TabControl&)
ELSEIF GETFOCUS (Button&[4])
MESSAGEBOX( Button 4 gewählt!, Testdialog,64)
SETFOCUS(TabControl&)
ELSEIF TABCHANGED(TabControl&)
SHOWWINDOW(LastTab&,0)
CASE GETACTIVETAB(TabControl&) = 0 : LastTab& = TabPage&[1]
CASE GETACTIVETAB(TabControl&) = 1 : LastTab& = TabPage&[2]
CASE GETACTIVETAB(TabControl&) = 2 : LastTab& = TabPage&[3]
CASE GETACTIVETAB(TabControl&) = 3 : LastTab& = TabPage&[4]
SHOWWINDOW(LastTab&,1)
SETFOCUS(TabControl&)
ELSEIF GETFOCUS(ChoiceBox&[1])
ButtonClick% = %LASTMESSAGE
IF (ButtonClick% > 306) AND (ButtonClick% < 310) Editfeld o.ä. war angewählt -> Reaktion des Buttons erst beim Loslassen
WAITINPUT
CASENOT GETFOCUS (ChoiceBox&[1]): ButtonClick% = 0
ENDIF
IF ButtonClick%
SETTEXT Edit&[1], GETTEXT$(ChoiceBox&[1])
ENDIF
ELSEIF GETFOCUS(ChoiceBox&[2])
ButtonClick% = %LASTMESSAGE
IF (ButtonClick% > 306) AND (ButtonClick% < 310) Editfeld o.ä. war angewählt -> Reaktion des Buttons erst beim Loslassen
WAITINPUT
CASENOT GETFOCUS (ChoiceBox&[2]): ButtonClick% = 0
ENDIF
IF ButtonClick%
SETTEXT Edit&[2], GETTEXT$(ChoiceBox&[2])
ENDIF
ELSEIF GETFOCUS(ChoiceBox&[3])
ButtonClick% = %LASTMESSAGE
IF (ButtonClick% > 306) AND (ButtonClick% < 310) Editfeld o.ä. war angewählt -> Reaktion des Buttons erst beim Loslassen
WAITINPUT
CASENOT GETFOCUS (ChoiceBox&[3]): ButtonClick% = 0
ENDIF
IF ButtonClick%
SETTEXT Edit&[3], GETTEXT$(ChoiceBox&[3])
ENDIF
ELSEIF GETFOCUS(ChoiceBox&[4])
ButtonClick% = %LASTMESSAGE
IF (ButtonClick% > 306) AND (ButtonClick% < 310) Editfeld o.ä. war angewählt -> Reaktion des Buttons erst beim Loslassen
WAITINPUT
CASENOT GETFOCUS (ChoiceBox&[4]): ButtonClick% = 0
ENDIF
IF ButtonClick%
SETTEXT Edit&[4], GETTEXT$(ChoiceBox&[4])
ENDIF
ENDIF
WEND
-----------------------------------------------------------------------------------------------
DESTROYWINDOW(Handle&)
-----------------------------------------------------------------------------------------------
ENDPROC
************************************************************************************************
************************************************************************************************
* Hauptfenster generieren *
************************************************************************************************
PROC Create_Desktop
+----------------------------------------------------------------------------------------------+
Hauptfenster erzeugen
+----------------------------------------------------------------------------------------------+
WINDOWSTYLE (1+2+4+8)
WINDOWTITLE Toolbar-Test
WINDOW 0, 0 - %MAXX, (~GetSystemMetrics(17)+~GetSystemMetrics(4))
SCREEN %MAXX, (~GetSystemMetrics(17)+~GetSystemMetrics(4))
USEICON A
CLS RGB(128,128,128)
+----------------------------------------------------------------------------------------------+
+----------------------------------------------------------------------------------------------+
Toolbar erzeugen:
+----------------------------------------------------------------------------------------------+
Create_Toolbar ($SysPath + \moricons.dll), 32, , 1
+----------------------------------------------------------------------------------------------+
AddToolbarButton ToolBar&, 100, 0, 2, 0, ToolbarText$[00,1], ToolbarText$[00,2]
+----------------------------------------------------------------------------------------------+
AddToolBarSeparator ToolBar&
+----------------------------------------------------------------------------------------------+
AddToolbarButton ToolBar&, 101, 0, 2, 1, ToolbarText$[01,1], ToolbarText$[01,2]
+----------------------------------------------------------------------------------------------+
AddToolBarSeparator ToolBar&
+----------------------------------------------------------------------------------------------+
AddToolbarButton ToolBar&, 102, 0, 0, 2, ToolbarText$[02,1], ToolbarText$[02,2]
AddToolbarButton ToolBar&, 103, 0, 0, 3, ToolbarText$[03,1], ToolbarText$[03,2]
AddToolbarButton ToolBar&, 104, 0, 0, 4, ToolbarText$[04,1], ToolbarText$[04,2]
AddToolBarSeparator ToolBar&
+----------------------------------------------------------------------------------------------+
SETFOCUS(%HWND)
+----------------------------------------------------------------------------------------------+
ENDPROC
+----------------------------------------------------------------------------------------------+
************************************************************************************************
* Hauptprogramm *
************************************************************************************************
CREATE_Desktop
POPUP &Toolbar Buttons
AppendMenu 100,Button0
AppendMenu 101,Button1
AppendMenu 102,Button2
AppendMenu 103,Button3
AppendMenu 104,Button4
+----------------------------------------------------------------------------------------------+
WHILENOT (%UMESSAGE=16) Beenden
+----------------------------------------------------------------------------------------------+
WAITINPUT
+----------------------------------------------------------------------------------------------+
LOCATE 10,1
IF %KEY=4
ToolbarResize(Toolbar&)
ELSEIF MenuItem(100)
PushedToolButton% = 100
PRINT Button 0 gedrückt.
ELSEIF MenuItem(101)
PushedToolButton% = 101
PRINT Button 1 gedrückt.
ELSEIF MenuItem(102)
CASE PushedToolButton%: ReleaseToolBarButton ToolBar&, PushedToolButton%
PushedToolButton% = 0
PRINT Button 2 gedrückt.
EnableTBButton(Toolbar&,100,0)
ELSEIF MenuItem(103)
CASE PushedToolButton%: ReleaseToolBarButton ToolBar&, PushedToolButton%
PushedToolButton% = 0
PRINT Button 3 gedrückt.
EnableTBButton(Toolbar&,100,1)
ELSEIF MenuItem(104)
CASE PushedToolButton%: ReleaseToolBarButton ToolBar&, PushedToolButton%
PushedToolButton% = 0
PRINT Button 4 gedrückt.
Dialog
ENDIF
WEND
+----------------------------------------------------------------------------------------------+
END
************************************************************************>************************
|
|