hallodri:
I am using examples that you actually provided with small changes:
iuplib_demo.pb:
Code: Select all
PrototypeC Icallback(*ih.Integer)
ImportC "iup.lib"
IupOpen()
IupMainLoop()
IupClose()
IupButton(title.p-utf8, action.p-utf8)
IupCbox(*handle, a=0, b=0, c=0) ;(...)
IupSetAttribute(*handle, name.p-utf8, value.p-utf8)
IupSetAttributes(*handle, str.p-utf8)
IupDialog(*handle)
IupShowXY(*handle, x.l, y.l)
IupStoreGlobal(*name, value.p-utf8)
IupGetGlobal(*name)
IupSetGlobal(name.p-utf8, value.p-utf8)
IupGetAttribute(*ih, name.p-utf8)
IupGetAttributes(*ih)
IupSetCallback(*ih.Integer, *name.Integer, func.Icallback)
IupSetFunction(*name.p-utf8, *func)
EndImport
#IUP_CENTER = $FFFF
#IUP_CLOSE = -3
Procedure button_action(*self)
Debug "Exit"
ProcedureReturn #IUP_CLOSE
EndProcedure
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure main()
IupOpen()
IupSetGlobal("UTF8MODE", "YES")
button = IupButton("Это просто кнопка", "NULL")
cbox = IupCbox(button)
IupSetAttribute(cbox, "EXPAND", "YES")
IupSetAttributes(button, "CX=200, CY=300")
IupSetAttribute(button, "FONT", "Times, Bold 18" )
IupSetCallback(button, "ACTION", @button_action())
dlg = IupDialog(cbox)
IupSetAttribute(dlg, "TITLE", "Hello World !");
IupSetAttribute(dlg, "RASTERSIZE", "800x600")
IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
IupMainLoop()
IupClose()
EndProcedure:main()
If I compile this example in ASCII mode - then I've got button callback working but all UNICODE staff lost.
If I use UNICODE mode - unicode labels displayed correctly, but callback not working.
After a bit of experiments I've got:
iuplib_demo1.pb
Code: Select all
PrototypeC Icallback(*ih.Integer)
ImportC "iup.lib"
IupOpen()
IupMainLoop()
IupClose()
IupButton(title.p-utf8, action.p-ascii)
IupCbox(*handle, a=0, b=0, c=0) ;(...)
IupSetAttribute(*handle, name.p-ascii, value.p-utf8)
IupSetAttributes(*handle, str.p-ascii)
IupDialog(*handle)
IupShowXY(*handle, x.l, y.l)
IupStoreGlobal(*name, value.p-ascii)
IupGetGlobal(name.p-ascii)
IupSetGlobal(name.p-ascii, value.p-ascii)
IupGetAttribute(*ih, name.p-ascii)
IupGetAttributes(*ih)
IupSetCallback(ih, name.p-ascii, *func)
IupSetFunction(*name.p-ascii, *func)
EndImport
#IUP_CENTER = $FFFF
#IUP_CLOSE = -3
Procedure button_action(*self)
Debug "Exit"
ProcedureReturn #IUP_CLOSE
EndProcedure
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure main()
IupOpen()
IupSetGlobal("UTF8MODE", "YES")
IupSetGlobal("DEFAULTFONT", "Times, Bold 10")
button = IupButton("Кнопка", "#NULL")
IupSetAttributes(button, "CX=200, CY=300")
IupSetAttribute(button, "FONT", "Times, Bold 10" )
IupSetAttribute(button, "SIZE", "200x" )
IupSetCallback(button, "ACTION", @button_action())
cbox = IupCbox(button)
IupSetAttribute(cbox, "EXPAND", "YES")
dlg = IupDialog(cbox)
IupSetAttribute(dlg, "FONT", "Times, Bold 10" )
IupSetAttribute(dlg, "TITLE", "Привет мир !");
IupSetAttribute(dlg, "RASTERSIZE", "800x600")
IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
IupMainLoop()
IupClose()
EndProcedure:main()
This time button callback working even if compiled in UNICODE mode, but main window title can't be set at all.
If I use ASCII mode and pass window title as pointer to ASCII string - then it's working...
Provided above samples tested with PureBasic 5.41/5.42 on Windows 64 bit. Libraries were created using method suggested by you.
P.S. As a side note - I've tested on to different workstations with Windows 10 x64 Pro. In one case I was able to get UNICODE button
label as presented in sample code above. But on second one that method was not working and I've got correct results only after changing
IupButton function definition to:
Code: Select all
IupButton(title.p-ascii, action.p-ascii)
Which is a bit strange.
P.P.S. Probably a separate thread have to be created dedicated to just these libs: IUP, CD and IM ?