Re: How to change the FXIcon in a FXButton at runtime?

Jeroen van der Zijp <[email protected]>
Newsgroups gmane.comp.lib.fox-toolkit.user
Organization FOX Toolkit
Message-ID <20220416190215.4513a485@leviathan>
On Sat, 16 Apr 2022 19:08:20 +0200
Pof <[email protected]> wrote:

>Dear all,
>
>In the MainWindow::MainWindow (derived from FXMainWindow):
>I create a FXButton and attach an FXIcon (icon1) to it:
>    btn = new FXButton(hframe,
>                         "",
>                         getApp()->icon1,
>                         this,ID_TRANSFORM,
>BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_CENTER_X|LAYOUT_CENTER_Y,
>                         0,0,0,0,0,0,0,0);
>
>Further on (outside the MainWindow constructor), I would like to be able 
>to change the icon (i.e. at runtime).
>Then I try:
>     btn->setIcon(getApp()->icon2);
>but this does not work, a MsgBox with "FXDCWindow:drawicon: illegal icon 
>specified" is shown, and then the program crashes.
>Any idea how to change the FXIcon in a FXButton at runtime?

Make sure the FXIcon has been created using create().

	icon->create()

This will give the icon its server-side representation, i.e. generate
the pixel data where the drawing routines can use then [the client-side
pixel buffer may often not be necessary anymore after this is done].


		-- JVZ



-- 
+----------------------------------------------------------------------------+
| Copyright (C) 19:00 04/16/2022 Jeroen van der Zijp.   All Rights Reserved. |
+----------------------------------------------------------------------------+


_______________________________________________
Foxgui-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/foxgui-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.