Author Topic: Color Dialog Demo  (Read 1454 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Color Dialog Demo
« on: September 23, 2020, 05:27:00 AM »
Code: [Select]
'color dialog
'
uses corewin
'
Type tCHOOSECOLOR
  lStructSize As Long
  hwndOwner As sys
  hInstance As sys
  rgbResult As Long
  lpCustColors As sys
  flags As Long
  lCustData As sys
  lpfnHook As sys
  lpTemplateName As sys
End Type
'
dim as int c            'returned color
dim as tCHOOSECOLOR cc  'color structure
cc.lStructSize=sizeof cc
cc.hwndOwner=0 'hwnd
cc.hInstance=GetModuleHandle 0
cc.flags=2 'fullopen
'some custom colors
dim as long cu(16)={
  0x0000ff,0x8080,0x00ff00,0x808000,0xff0000
}
cc.lpCustColors=@cu
'
c=ChooseColor @cc
print hex(cc.rgbResult,6)
« Last Edit: September 23, 2020, 05:35:40 AM by Charles Pegge »

JRS

  • Guest
Re: Color Dialog Demo
« Reply #1 on: September 23, 2020, 07:37:32 AM »
IUP News about color dialog use.

IupColorDlg

Seems to work for me.

Code: Script BASIC
  1. IMPORT iup.sbi
  2.  
  3. CONST IUP_CURRENT = 0xFFFB
  4.  
  5. Iup::Open()
  6.  
  7. dlg = Iup::ColorDlg()
  8.  
  9. Iup::SetAttribute(dlg, "VALUE", "128 0 255")
  10. Iup::SetAttribute(dlg, "ALPHA", "142")
  11. Iup::SetAttribute(dlg, "SHOWHEX", "YES")
  12. Iup::SetAttribute(dlg, "SHOWCOLORTABLE", "YES")
  13. Iup::SetAttribute(dlg, "TITLE", "IupColorDlg Test")
  14. ' Iup::SetCallback(dlg, "HELP_CB", (Icallback)help_cb)
  15.  
  16. Iup::Popup(dlg, IUP_CURRENT, IUP_CURRENT)
  17.  
  18. IF Iup::GetInt(dlg, "STATUS") THEN
  19.   PRINT "OK\n"
  20.   PRINT FORMAT("  COLOR(%s)\n", Iup::GetAttribute(dlg, "VALUEHEX"))
  21.   PRINT FORMAT("  COLORTABLE(%s)\n", Iup::GetAttribute(dlg, "COLORTABLE"))
  22. ELSE
  23.   PRINT "CANCEL\n"
  24. END IF
  25.  
  26. Iup::Destroy(dlg)
  27.  
  28. Iup::Close()  
  29.  


C:\ScriptBASIC\examples>sbc iup_cd.sb
OK
  COLOR(#FF00A8)
  COLORTABLE(0 0 0;64 64 64;128 128 128;144 144 144;0 128 128;128 0 128;128 128 0;128 0 0;0 128 0;0 0 128;255 255 255;240 240 240;224 224 224;192 192 192;0 255 255;255 0 255;255 255 0;255 0 0;0 255 0;0 0 255)

C:\ScriptBASIC\examples>


« Last Edit: September 23, 2020, 06:18:37 PM by John »

Charles Pegge

  • Guest
Re: Color Dialog Demo
« Reply #2 on: September 23, 2020, 09:02:50 PM »
Hi John,

This is IUP's own Color dialog:

Quote
(since IUP version 3.24 the native versions were removed and only the IupColorBrowser based dialog remains.)

JRS

  • Guest
Re: Color Dialog Demo
« Reply #3 on: September 24, 2020, 07:13:01 AM »
I like the IUP color dialog better and it seems easier to use.

Your O2 example attached.

It would be great if you could make Windows styles enabled as a default. Both SBC (console) and SBW (Windows) interpreters have Windows style support enabled by default. I can't see when you wouldn't want styles enabled.

The only time I have disabled Windows styles is for the progress control. With my VB6 ActiveX DLL forms I can disable styles at the component level.

I only use IUP for Linux now and VB6 as my GUI toolkit for Windows. I would use O2 more if it had a CallByName COM/OLE automaton  interface. Supporting variants and safe arrays would be a first good step.

My only regret is I wish I had the VB6 / SB connection 10 years ago. Life under Windows is so much better now. VB6 as a UI frontend for a SB multi-threaded process application works great with minimum CPU utilization.



« Last Edit: September 26, 2020, 07:09:53 AM by John »