Vista Textbox/gadget cue banner.

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Vista Textbox/gadget cue banner.

Post by Rescator »

ComboBox and StringGadget initial "Choose" text.
Compile as unicode unless you ant to mess around with PeekS and PokeS to convert the text for SendMessage.

Code: Select all

#ECM_FIRST=$1500
#EM_SETCUEBANNER=#ECM_FIRST+1
#CB_SETCUEBANNER=$1703

  If OpenWindow(0, 0, 0, 270, 140, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    ComboBoxGadget(0, 10, 10, 250, 100, #PB_ComboBox_Editable)
    AddGadgetItem(0, -1, "ComboBox editable...")
    SendMessage_(GadgetID(0), #CB_SETCUEBANNER, 0, "Choose or enter:");
    ComboBoxGadget(1, 10, 40, 250, 100)
    For a = 1 To 5 : AddGadgetItem(1, -1,"ComboBox item " + Str(a)) : Next a
;    SetGadgetState(1, 2)    ; set (beginning with 0) the third item as active one
    SendMessage_(GadgetID(1), #CB_SETCUEBANNER, 0, "Select an option:");
    StringGadget(2, 10, 70, 250, 20,"")
    SendMessage_(GadgetID(2), #EM_SETCUEBANNER, 0, "Enter text:");
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
Last edited by Rescator on Wed Sep 03, 2008 8:00 am, edited 1 time in total.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Doesn't work unless you compile it as unicode compatible, then it works well. :wink:
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Well considering this is for Vista I don't think that is an issue :)
After all, 2000, XP, 2003, Vista, 2008, are all unicode. So unless you need to support Win9x I do not see any reason to compile as anything, my default is always unicode these days.

Thanks for pointing that out though, not sure about SendMessage but I know some API calls do not always have A and W variants.

So if anyone are making a Vista or Vista compatible app and want to use this feature then PeekS() and PokeS() must be used to convert a ascii string to unicode before sending the text to the gadget via SendMessage().

Oh yeah, you also need XP Theme enabled for these to show anything.
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Post by Seldon »

Nice trick ! Thank you ! Do you know how is it possible to set the italic style for it ???
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

No idea, it seems automatic and part of the OS GUI. I have not checked if this works on XP SP2 it might. I doubt it works on 2000 though.
Post Reply