English
Source / code snippets

Bitmap Button lever Static allocate

 
Simple example circa one lever (Button or Static) one Bitmap zuzuweisen.

CompileMarkSeparation
declare oid_dateiname#
DEF Createpicstatic(6) control(STATIC,@$(2),$5400010E,@%(3),@%(4),@%(5),@%(6),@%(1),2000, %HInstance)
DEF Createpicbutton(6) Control(BUTTON,@$(2),$50000080,@%(3),@%(4),@%(5),@%(6),@%(1),2000,%hinstance)
DEF Createpicbutton_od(6) Control(BUTTON,@$(2),$50000000+128+32768,@%(3),@%(4),@%(5),@%(6),@%(1),1000,%hinstance)
DEF LoadImage(6) !USER32,LoadImageA

proc oid_pic2hdl

    String oid_dateiname#,0=@$(1)
    return LoadImage(%HInstance,oid_dateiname#,0,0,0,$00050)

endproc

proc oid_pic2static

    parameters static&,pic&
    Sendmessage(static&,$172,0,pic&)

endproc

proc oid_pic2button

    parameters static&,pic&
    Sendmessage(static&,$00F7,0,pic&)

endproc

print
dim oid_dateiname#,256
oid_pic2button Createpicbutton_od(%hwnd,teeeest,10,10,100,100),oid_pic2hdl(xprofan.bmp)
oid_pic2button Createpicbutton(%hwnd,teeeest,220,10,100,100),oid_pic2hdl(xprofan.bmp)
oid_pic2static Createpicstatic(%hwnd,teeeest,110,10,100,100),oid_pic2hdl(xprofan.bmp)
dispose oid_dateiname#
waitinput
Please mind the too one XProfan.bmp in the equal directory lying.

iF
 
06/28/04  
 




Ragnar
Rehbein
by me is no buttontext visible.
can the someone confirm ?

r.r.
 
06/29/04  
 



very, no Buttontext, is yes a Bitmap-Button. must only hereon respect that you too one such XPROFAN.BMP in the directory have, or simply on one other BMP show.

iF
 
06/29/04  
 




Ragnar
Rehbein
the teeeest having me suggeriert, the graphic + Text on the button is.
I had me gefreut, if it too a possibility without The skcontrol.dll given had.

r.r.
 
06/29/04  
 



Kappier I somehow Nich, one Button is still either Bitmap, or Text. Schreib still whom Text on The graphic.

the went Yes even automatisiert (program) the z.B. the Bitmap first in memory(bitmap) generiert becomes, and then on the But laid.

iF
 
06/29/04  
 




Ragnar
Rehbein
means I use often bottons The a Text include and right or left moreover one icon. simply because it nice looks.
the Text is with some programmen by ini konfigurierbar.

with bitmaps would the hoisted a Text or a buttongröße To Change plenty larger. moreover would the only klappen if I The bitmap to laufzeit create, there the button yes to whom gewählen systemfarben fit should. transparency How with icons is with bitmaps well you don't say so. I should means whom area the in in a icon transparent is properly with of/ one colour, The to systemfarbe harmoniert fill and the Test hereon place.

yet use I The skcontrol.dll.
these has however too detriments. I can z.b. no bottonstyles allocate.
a reasonable togglebotton to create, can itself only over userbottons regulate, where I instead of 3 at least 4 or 5 bitmaps bräuchte, if ichs not only einrasten separate too hovern let wants.

thereby would me already one small niedliches icon on one windows-togglebutton happy make.

i'm certainly not oberflächenvernarrt, but a little bit nice ought to it looks and it should itself slight Change let.

the whole sees then z.b. so from:

[img:ce134c3423]https://www.family-rehbein.de/presentment1.JPG[/img:ce134c3423]
sure not überragend, but somehow rather as only buttons.
quick to create and quick To Change.
and hoovern dank the skcontrol.dll

r.r.
 
06/29/04  
 



Hmmm, Perhaps a Buttonkonstrukt over Subclassing release? too ne Own small DLL as 2. Thread could slight manage what You there describe. it went me here however vordergründig circa Bitmap-Buttons, not circa Icon-Buttons. i see however very well your border, have but unfortunately none Source parat (or in the head) the you there quick help on could. Sogern I you there help on would like....:|

Argh, still, now falls me what a, Perhaps helps you one ploy, insert Bitmap-Static on the Button on, so have You still your icon. of course immernoch without Transparents, but with a thin welt the down versenkt works, would the even integrally nice looks. so have You your Standart-Button, with nem Bitmap-Static on it. Hmmm, though, if one then over Static hoovern would could one Yes not whom Button clicking, hmmm, means neither the true.

To denne, iF
 
06/29/04  
 




Uwe
''Pascal''
Niemeier
Hello people!

I use for these routine:
CompileMarkSeparation
window 20,20-500,300
declare dlg&,a&,b&,a#
dim a#,255
 $H Messages.ph
 $H Windows.ph

proc IconButton---------------------------------------------------------------

    parameters Button&,Icon&
    declare bmp&,CDC&,Breite%,Höhe%,Text$,Brush&
    bmp&=sendmessage(Button&,~BM_GETIMAGE,0,0)-Schon Bitmap vorhanden?
    case bmp&:deleteobject bmp&----------------Löschen!
    casenot Icon&:return-----------------------Kein neues Icon? => Ende
    setstyle Button&,$54010080-----------------Style IconButton
    Breite%=width(Button&)
    Höhe%=height(Button&)
    Text$=gettext$(Button&)
    CDC&=~CreateCompatibleDC(%hdc)
    bmp&=~CreateCompatibleBitmap(%hdc,Breite%,Höhe%)
    ~SelectObject(CDC&,bmp&)
    ~SetBkMode(CDC&,~TRANSPARENT)--------------keine Hintergrundfarbe für Text
    Brush&=~GetSysColorBrush(~COLOR_3DFACE)----Hintergrund Systemfarbe
    ~SelectObject(CDC&,Brush&)
    ~Rectangle(CDC&,0,0,Breite%,Höhe%)---------Button mit Systemfarbe füllen
    ~DrawIcon(CDC&,2,2,Icon&)------------------Icon zeichnen (Abstand Rand 2,2)
    clear a#
    long a#,0=34-------------------------------Text beginnt hinter Icon
    long a#,8=Breite%
    long a#,12=Höhe%---------------------------Text wird vert. zentriert => Ganze Höhe angeben
    ~DrawText(CDC&,addr(Text$),len(Text$),a#,~DT_SINGLELINE | ~DT_CENTER | ~DT_VCENTER)
    ~DeleteDC(CDC&)
    deleteobject Brush&
    sendmessage(Button&,~BM_SETIMAGE,0,bmp&)--Bitmap zuweisen
    endproc-----------------------------------------------------------------------
    dlg&=create("dialog",%hwnd,"",200,200,300,300)
    a&=create("Button",dlg&,"Testbutton",110,10,110,40)
    b&=~LoadImageA(%hinstance,"A",~IMAGE_ICON,0,0,~LR_LOADREALSIZE)
    IconButton a&,b&
    waitkey
    b&=~LoadImageA(%hinstance,"Gesicht",~IMAGE_ICON,0,0,~LR_LOADREALSIZE)
    IconButton a&,b&
    waitkey
    IconButton a&,0
    end

the can itself discretionary changing, circa z.B. coloured Buttons or Buttons with farbigem Text and beliebigem Font To produce (very useful for ChooseFont-Aufrufe). or one could the Text under the Button Show etc.
derogatory is only, that one for The graphic-API bring into action must. if to the Mainwindow not directly need (z.B. because it of a rahmenlosen dialog ausgefüllt becomes or sonstwie invisible is), can its Buttons too with the Profan-Grafikbefehlen design:
CompileMarkSeparation
window 20,20-500,300
settruecolor 1
 $H Messages.ph
 $H windows.ph
declare dlg&,a&

proc DrawButton---------------------------------------------------------------

    parameters Button&,Icon$
    declare bmp&,CDC&,wide%,Höhe%,Color&,Text$
    bmp&=sendmessage(Button&,~BM_GETIMAGE,0,0)-already Bitmap present?
    case bmp&:deleteobject bmp&----------------Delete!
    casenot len(Icon$):return------------------no new Icon? => end
    setstyle Button&,$54010080-----------------Style IconButton
    wide%=width(Button&)
    Höhe%=height(Button&)
    Color&=~GetSysColor(15)
    Text$=gettext$(Button&)
    cls-------------with Standart-command in that Mainwindow draw
    usebrush 1,Color&
    usepen 0,1,Color&
    rectangle 0,0-wide%,Höhe%
    drawicon Icon$,2,2
    textcolor rgb(255,0,0),-1
    drawtext 36,9,Text$
    CDC&=~CreateCompatibleDC(%hdc2)
    bmp&=~CreateCompatibleBitmap(%hdc2,wide%,Höhe%)
    ~SelectObject(CDC&,bmp&)
    ~BitBlt(CDC&,0,0,wide%,Höhe%,%hdc2,0,0,$CC0020)
    ~DeleteDC(CDC&)
    sendmessage(Button&,~BM_SETIMAGE,0,bmp&)
    endproc-----------------------------------------------------------------------
    dlg&=create("dialog",%hwnd,"",200,50,300,300)
    a&=create("Button",dlg&,"Testbutton",50,50,120,40)
    DrawButton a&,"A"
    waitkey
    DrawButton a&,"Gesicht"
    waitkey
    DrawButton a&,""
    end

PS: there can itself naturally yet much improve, but I be now time no friend vorgekauter Solutions

HTH
Pascal
 
06/30/04  
 




Michael
Dell
beautiful example Pascal, but too Ifs example can one bißschen modifiziert go. man set simply nochn Kontrol on the Button.
CompileMarkSeparation
Def GSC(1) !"USER32","GetSysColor"
Def GBackC(0) GSC(15)
declare Aus&,oid_dateiname#,pb2&,pb2_txt&
© Andreas Miethe , Bielefeld , 1998
DEF Createpicstatic(6) control("STATIC",@$(2),$5400010E,@%(3),@%(4),@%(5),@%(6),@%(1),2000,%HInstance)
DEF Createpicbutton(6) Control("BUTTON",@$(2),$50000188,@%(3),@%(4),@%(5),@%(6),@%(1),2000,%hinstance)
DEF Createpicbutton_od(6) Control("BUTTON",@$(2),$50000000+128+32768,@%(3),@%(4),@%(5),@%(6),@%(1),1000,%hinstance)
DEF LoadImage(6) !"USER32","LoadImageA"

PROC ButtonText

    SetText &(1),$(2)

ENDPROC

proc oid_pic2hdl

    String oid_dateiname#,0=@$(1)
    return LoadImage(%HInstance,oid_dateiname#,0,0,0,$00050)

endproc

proc oid_pic2static

    parameters static&,pic&
    Sendmessage(static&,$172,0,pic&)

endproc

proc oid_pic2button

    parameters static&,pic&
    Sendmessage(static&,$00F7,0,pic&)

endproc

SetTrueColor 1
Cls GBackC()
dim oid_dateiname#,256
oid_pic2button Createpicbutton_od(%hwnd,"Teeeest1",10,10,100,100),oid_pic2hdl("xprofan.bmp")
pb2& = Createpicbutton(%hwnd,"Teeeest2",220,10,400,100)  geändert
oid_pic2button pb2&,oid_pic2hdl("xprofan.bmp")
pb2_txt& = control("STATIC","",$54000081,104,39,292,22,pb2&,2000,%HInstance)
oid_pic2static Createpicstatic(%hwnd,"Teeeest3",116,60,100,100),oid_pic2hdl("xprofan.bmp")
ButtonText(pb2_txt&,"Hallolo")
dispose oid_dateiname#
Aus& = 0

WhileNot Aus&

    WaitInput

    If Equ(%Key,-2)

        Aus& = 1

    ElseIf GetFocus(pb2&)

        ButtonText(pb2_txt&,"Schöööön...")

    Else

        ButtonText(pb2_txt&,"Hallolo")

    EndIf

EndWhile
ass=s4 href='./../../Function-References/XProfan/end/'>End

leaves itself, mean so did i integrally well on.

To denne... Michael
 
Salu Michael...

Hab zwar krumme Fieß awer dofir e' ecklich Gsicht! 
07/01/04  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

10.315 Views

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie