Announcement

Collapse
No announcement yet.

Icon ID through one param

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Egbert Zijlema
    replied
    I've updated the code. Now it depends of the language identifier which button text will be used: Dutch, German (partly, did'nt know all the words) or English when Dutch and German don't apply.

    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    [This message has been edited by Egbert Zijlema (edited March 13, 2001).]

    Leave a comment:


  • Egbert Zijlema
    replied
    Semen,

    I agree with you at 2 points:
    1. It surely does not work with Russian (=Cyrillian) charset, nor with Greek, Japanese, Chinese etc. On 'Latin' computers it works, as long as you don't use accented chars.
    2. If someone wants to use it on his own computer only and its Windows version is in his/her own language, you don't need this. The code is ment for those who want to create a multi-language message box.

    I'll update the code a bit in order to show what I mean.

    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Leave a comment:


  • Semen Matusovski
    replied
    Egbert --
    I looked your code and see that it can't work correctly.
    Imagine, that I want to display Russian Yes / No.
    If local settings are Russian, it's possible to use standart msgbox.

    So, let's assume non-Russian regional settings.
    If to use your code directly, it will be abra-kadabra (wrong charset).
    So, first of all, it's necessary to set a font for buttons (with correct lf.lfCharset).

    This will work under 9x. But under Win2000 (and probably NT4 - I didn't test) standart buttons and static ignore lf.lfCharset.
    Alone way to write Russian letters in buttons on Dutch PC, Win2000 is to use TextOut (owner-drawn).

    ------------------
    E-MAIL: [email protected]

    Leave a comment:


  • Eric Pearson
    replied
    Sorry if I misunderstood. I thought the basic problem was that some icons were identified with numbers and some with strings, and you wanted to be able to use both. You solved it by assigning numbers to your icons, which is the way I would do it, but I believe you also could have solved it by using strings for the native Windows icons, like "#32513" for IDI_HAND.

    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Egbert Zijlema
    replied
    Eric,

    This is not the problem here.
    I want to pass an icon-ID thru a procedure's param. Since default Windows icons have numeric ID's (%IDI_WINLOGO, for example) I want to pass icon-ID's from the application's resource file as numerics as well.
    This is the idea: SUB Dialog(caption AS STRING, icon AS LONG, msgText AS STRING).
    Well, as said: I found the solution by defining my icons as numeric within the resource file.

    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Leave a comment:


  • Eric Pearson
    replied
    Egbert --

    I never do it this way because numeric IDs are more efficient, but if I'm not mistaken you can do it with 100% strings too. Like "MyIcon" and "#1234". Windows sees the # and interprets the string as a number.

    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Egbert Zijlema
    replied
    I've solved the problem myself. In the .RC file you have to #define the icons, in order to give them a long integer handle. In your application you can define equates of the same value and use these in: LoadIcon(applHndl, BYVAL %ICONEQUATE).
    See: my new messagebox code in the source code forum.

    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    [This message has been edited by Egbert Zijlema (edited March 13, 2001).]

    Leave a comment:


  • Semen Matusovski
    replied
    Egbert --
    take a look
    Code:
       #Compile Exe
       #Dim All
       #Register None
       #Include "win32api.INC"
       #Resource "test.pbr"
       
       ' Resouce file:
       '% ANYNAME ICON HASP.ICO
       '% 101 ICON LTR.ICO
       
       Sub SetIcon (hWnd As Long, Value As Asciiz Ptr)
          If CDwd(Value) <= 32767 Then
             DeleteObject SendMessage (hWnd, %WM_SETICON, %ICON_BIG, LoadIcon(ByVal 0&, ByVal Value))
          ElseIf Left$(@Value, 1) = "#" Then
             DeleteObject SendMessage (hWnd, %WM_SETICON, %ICON_BIG, LoadIcon(GetModuleHandle(""), ByVal Val(Mid$(@Value, 2))))
          Else
             DeleteObject SendMessage (hWnd, %WM_SETICON, %ICON_BIG, LoadIcon(GetModuleHandle(""), @Value))
          End If
       End Sub
    
       CallBack Function Proc1
          SetIcon CbHndl, ByVal %IDI_ASTERISK
       End Function
    
       CallBack Function Proc2
          SetIcon CbHndl, "ANYNAME"
       End Function
       
       CallBack Function Proc3
          SetIcon CbHndl, "#101"
       End Function
    
       Function PbMain
          Local hDlg As Long
          Dialog New 0, "Test", , , 100, 80, _
             %WS_CAPTION Or %WS_SYSMENU Or %WS_MAXIMIZEBOX Or %WS_MINIMIZEBOX Or %WS_THICKFRAME To hDlg
          Control Add Button, hDlg, 101, "IDI_ASTERISK", 10, 10, 80, 14 Call Proc1
          Control Add Button, hDlg, 102, "ANYNAME", 10, 30, 80, 14 Call Proc2
          Control Add Button, hDlg, 103, "101", 10, 50, 80, 14 Call Proc3
          Dialog Show Modal hDlg
      End Function
    ------------------
    E-MAIL: [email protected]

    Leave a comment:


  • Edwin Knoppert
    replied
    See my site for the helpfile i wrote.
    Topic : "LoadIconOrCursorFromRes" explains loading by id.
    Every icon HAS an id in the resource, a small adjustment for you..


    ------------------

    Leave a comment:


  • Egbert Zijlema
    started a topic Icon ID through one param

    Icon ID through one param

    Hi Fellows,

    I want to pass an icon through a procedure that builds a dialog. This icon maybe either one of the 6 default Windows icons (%IDI_QUESTION and those) or an icon from the application's resource file.
    The problem is that windows' default icons have a long integer ID, while icons in the .PBR file are referred to as string literals.
    How can I overcome that difference, using only 1 param with the procedure? I tried 'ID_Icon AS ANY' here, but PB does not seem to know that one.
    To make myself clear: I don't want to load the icon in advance (i.e. just before calling the sub) and then pass its handle (too much overhead I'm afraid). The icon should be loaded within the procedure.


    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/
Working...
X