#974 oodialog 4.2 Application icon method addIconResource

ooDialog.4.2.0
closed
ooDialog (58)
none
5
2013-11-22
2011-01-02
hex
No

According to the manual if there is an icon resource in a resourcescript the icon will be loaded and used in the dialog automatically(method
addIconResource is automatically invoked) by using the symbolicname (IDI_ICON in this case) in
dlg~execute("SHOWTOP",IDI_ICON)

I can't get it to work without adding
dlg~addIconResource(IDI_ICON, "iconfilename.ico")
dlg~execute("SHOWTOP",IDI_ICON)

If a resource file doesn't contain any icon resource, you can use -addIconResource(--id--,--fileName--
where id can be numeric or Symbolicname

This I also can't get to work as expected,
dlg~addIconResource(IDI_ICON, "iconfilename.ico")
dlg~execute("SHOWTOP",IDI_ICON)

but replacing symbolicname with a numeric value then it works
dlg~addIconResource(2000, "iconfilename.ico")
dlg~execute("SHOWTOP",2000)

Discussion

  • Mark Miesfeld

    Mark Miesfeld - 2011-01-02

    Two working example programs for icon resources

     
    Attachments
  • Mark Miesfeld

    Mark Miesfeld - 2011-01-02

    I attached a zip file with two working programs. One uses a .rc file and has an icon resource statement in it, and it works. The other uses addIconResource() with an UserDialog and a symbolic ID, and it also works.

    Now, when using a .rc file, currently the ICON resource statement has to come before the Dialog resource statement to be found. The reason is that the parser stops once it locates the Dialog to be used for the program.

    ResEdit always puts the ICON resource statements after the Dialog resources. I always move the ICON resource statements ahead of the Dialog resource statements. Which I admit is a pain, but I didn't think any one but myself used icons from a .rc script. So, I fixed that.

    Committed revision 6538.
    This commit fixes the .rc parser so that it locates any ICON resource statements in the .rc file.

    As to this:

    "If a resource file doesn't contain any icon resource, you can use -addIconResource(--id--,--fileName--
    where id can be numeric or Symbolicname

    This I also can't get to work as expected,
    dlg~addIconResource(IDI_ICON, "iconfilename.ico")
    dlg~execute("SHOWTOP",IDI_ICON)
    "

    This works correctly as far as I can tell. You'll need to attach an example program that shows it not working. You should check the return from addIconResource(), a -1 indicates failure:

    -1
    A problem with the resource ID. Either a symbolic ID could not be resolved, or the ID is
    reserved.

    So, the problem could be that your IDI_ICON is not a valid symbolic ID, or it is a reserved ID.

    I intend to put up a new ooDialog 4.2.0 beta release today. It will have all the fixes I've made to date and all the updates to the doc.

     
  • hex

    hex - 2011-01-02

    I got the impression that when using
    dlg~addIconResource(IDI_ICON, "iconfilename.ico")
    dlg~execute("SHOWTOP",IDI_ICON)
    and the symbolic id IDI_ICON is not in any resource file or elsewhere defined, it will be created in the constdir by addIconResource and then be usable in the execute statement, If changing to a numeric value all works, I suspected that the numeric value was created/kept somewhere (constdir ?) and then usable in the dialog execute statement, I assumed that the same was true for an symbolic id BUT I now realize that there is no numeric value defined for the symbolic id so it can't work with a symbolic id as I expected. My bad
    I am satisfied with the solution of the resource parsing, indepent of where the ICON statement is in the script

     
  • Mark Miesfeld

    Mark Miesfeld - 2011-01-10

    Fixed in ooDialog 4.2.0 (beta) r6569 now on SourceForge.

    From hexit32:

    I got the impression that when using
    dlg~addIconResource(IDI_ICON, "iconfilename.ico")
    dlg~execute("SHOWTOP",IDI_ICON)
    and the symbolic id IDI_ICON is not in any resource file or elsewhere
    defined, it will be created in the constdir by addIconResource"

    No that is not the case. I'm not sure why you have that impression. Anywhere symbolic IDs are acceptable, the symbolic ID has to already have been placed in the constDir. The only time the ooDialog framework places symbolic IDs in the constDir is when it reads and parses a .h file or a .rc file and comes to a

    define SOME_SYMBOIC_ID 150

    statement.

     
  • Rick McGuire

    Rick McGuire - 2013-11-22
    • Pending work items: --> none
    • Group: v4.2.0 --> ooDialog.4.2.0
     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks