RegisterIcon() in a Dialog plugin?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/10/2011 at 09:07, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;---------
Is it possible to register an icon through a dialog plugin?I've seen this code example floating around:
GetCustomIconData *icon =((GetCustomIconData* )data); GetIcon(200000000,icon->dat); icon->filled=TRUE;
But that is for object and tag type of plugins.
Dialog type plugins don't have a *data parameter to overload. And when I do something like this:void *data; GetCustomIconData *icon =((GetCustomIconData* )data); //Crashes!! GetIcon(200000000,icon->dat); icon->filled=TRUE;
C4D crashes
Anyone know what I'm doing wrong?
Is this even possible?-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/10/2011 at 11:20, xxxxxxxx wrote:
Originally posted by xxxxxxxx
void *data; GetCustomIconData *icon =((GetCustomIconData* )data); //Crashes!! GetIcon(200000000,icon->dat); icon->filled=TRUE;
Ouch, you are working with a undefined pointer.
You can allocate the IconData on the stack. Something like this:
IconData data; GetIcon(200000000,&data); data.filled = TRUE;
Please read up on memory allocation, pointers and the stack, it's basic C/C++ knowledge, otherwise you will always run into these kind of problems/crashes.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/10/2011 at 12:07, xxxxxxxx wrote:
Thanks,
I'm using your code example in the myDialog::InitValues(void). And I'm getting an error:
data.filled = TRUE; // ERROR. IconData has no member "filled"
Here is my registration code just in case that's important:
Bool RegistermyResDialog(void) { Filename fn = GeGetPluginPath()+"res"+"myimage.jpg"; //The file path where the icon image is located AutoAlloc<BaseBitmap> bmp; if (IMAGERESULT_OK != bmp->Init(fn)) return FALSE; //Don't register the plugin if the image is not present GePrint("image loaded"); // <-----------This does show up in the console when C4D is launced RegisterIcon(200000000,bmp,0*32,0,32,32, ICONFLAG_COPY); String sName, sHelp; sName = GeLoadString(IDS_RESDIALOG); // load the plugin name from the global string table - this will appear in the Plugins menu sHelp = "Example CommandData plugin with a dialog box"; // this string appears in the status bar when the user hovers over the plugin name in the menu (could be loaded from the string table, of course) return RegisterCommandPlugin(IDS_RESDIALOG, sName, 0, AutoBitmap("icon.tif"),sHelp, gNew myResDialog); }
I'm sure I'm missing something really simple.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/10/2011 at 12:29, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Thanks,
I'm using your code example in the myDialog::InitValues(void). And I'm getting an error:
data.filled = TRUE; // ERROR. IconData has no member "filled"
Sorry about that. I was just copy/pasting form the forum
What is your final goal, e.g. what do you want to do with the icon? The retrieved IconData structure gives you access to the icon bitmap and its dimensions.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/10/2011 at 12:43, xxxxxxxx wrote:
I'm trying to apply my own registered icon image to a button(both standard & customGUI type buttons).
Here's a snippet of code from my CreateLayout(void) method:
BaseContainer bbc; // Create the containers for Custom GUI's GroupBegin(0,BFH_SCALEFIT|BFV_SCALEFIT,0,1,String(),0); bbc.SetLong(BITMAPBUTTON_BORDER, BORDER_OUT); bbc.SetBool(BITMAPBUTTON_BUTTON, TRUE); myButton = (BitmapButtonCustomGui* )AddCustomGui(10001,CUSTOMGUI_BITMAPBUTTON,"MY BUTTON", 0L,150,150,bbc); //Adds the BitmapButton GUI to the dialog //myButton->SetImage(Osphere, FALSE); //Adds the sphere icon to the button if desired myButton->SetImage(200000135, FALSE); //Adds the gradient icon to the button if desired GroupEnd();
I'd like to use my own registered icon image in place of Osphere, or 200000135(the gradient's id#).
Keeping in mind that this is a dialog plugin.I came up with this little diddy:
IconData data; GetIcon(200000000,&data); GetCustomIconData *icon =((GetCustomIconData* )&data); if (!GetIcon(200000000,&data)) GePrint("geticon error!"); //<--This does print..So I'm not loading my icon properly icon->filled=TRUE;
What happens is the plugin runs fine. But the icon doesn't show up on my button.
I'm also not sure where the best place is to put this code(under which method?).-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/10/2011 at 18:00, xxxxxxxx wrote:
Never mind Matthias. I found the problem.
It wasn't a code problem. The image I was using was way too big.I had thought that I could use a largish image and then target certain pixel areas like how the noises.tif has multiple image tiles in it. But apparently if you go too big. It doesn't show up at all.
Sorry for the wild goose chase.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/10/2011 at 17:23, xxxxxxxx wrote:
I'm glad you figured it out on your own.
cheers,
Matthias