Announcement

Collapse
No announcement yet.

Icon again

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

  • Icon again

    Hello,

    Doing a search thru the Windows forum I found several solutions to include an icon in a dialog.
    It does not work. What I want is a dialog that should be a lookalike
    of a yes/no messagebox. It should display the default questionmark. Not in the
    caption bar, by the way, but in the dialog itself. Here's the callback code (as you can see, I've tried them all):
    Code:
    CALLBACK FUNCTION IconInclude()
      LOCAL hIcon AS LONG
      
      SELECT CASE CBMSG
        CASE %WM_INITDIALOG
          hIcon = LoadIcon(BYVAL %NULL, BYVAL %IDI_QUESTION)
          ' SendMessage CBHNDL, %WM_SETICON, %ICON_BIG, hIcon 
          DIALOG SEND CBHNDL, %WM_SETICON, %ICON_BIG, hIcon
          ' SetClassLong CBHNDL, %GCL_HICON, hIcon
      END SELECT
    END FUNCTION
    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Try this one (you need a label or so as 'carrier' for the icon) ...
    Code:
    #Compile Exe
    #Include "Win32api.inc"
    Global hDlg As Long
    
    CallBack Function IconInclude()
    Local hIcon As Long
    Select Case CbMsg
      Case %WM_INITDIALOG
        Control Add Label, hDlg&, 9000, "",10, 5, 25, 25,%SS_ICON
        Control Add Button, hDlg&, 9001, "OK",50, 10, 25, 15
        hIcon = LoadIcon(ByVal %NULL, ByVal %IDI_QUESTION)
        Control Send hDlg, 9000, %STM_SETIMAGE, %IMAGE_ICON, hIcon
      Case %WM_COMMAND
        Select Case CbCtl
          Case 9001
            Dialog End hDlg
        End Select
    End Select
    End Function
    
    Function PbMain() As Long
      Dialog New 0 , "Testing...",,, 100, 40, To HDlg
      Dialog Show Modal hDlg, Call IconInclude
    End Function
    ------------------
    Peter.
    mailto[email protected][email protected]</A>

    [This message has been edited by Peter Lameijn (edited October 21, 2000).]
    Regards,
    Peter

    Comment


    • #3
      Peter,

      Thanks very much.
      Where did you find this information? I searched both 'bibles', Petzold and Brent/Newcomer, for it but did'nt find. To begin with: creating a label with the %SS_ICON-style was completely new for me. PBDLL's on-line help does not mention it at all!

      Secondly: I knew how to load an icon for the caption bar (in fact: how to change the default SYSMENU-icon into one of your own). The message to use there is WM_SETICON. So, my simple mind told me to do the same for a control. But that's a quite different thing, obviously. As said, I did'nt find this info. Nor did I see examples when searching PB's message boards on "icons". All messages found only discuss the caption bar icon.

      One additional question: do you also know how to disable the close button (I mean: the 'x' in the right upper corner)? The PBDLL editor uses itself in its error messages dialog.


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

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment


      • #4
        To disable the close button

        Code:
           Dialog New 0 , "Testing...",,, 100, 40, To HDlg 
        
           SysMenu& = GetSystemMenu (hDlg, %FALSE)
           DeleteMenu SysMenu&, %SC_CLOSE, 0   
        
           Dialog Show Modal hDlg, Call IconInclude

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

        Comment


        • #5
          Egbert,

          I found demo code some time ago (somewhere on the BBS, don't remember where)
          There is some useful info in the win32api helpfile under "Static Controls"
          Normally you could also use Control Add Image ..., but that only seems to work with images embedded in the resourcefile, not with system icons.



          ------------------
          Peter.
          mailto[email protected][email protected]</A>
          Regards,
          Peter

          Comment


          • #6
            DDT image controls need to be initially loaded with a image from a resource file, but can be subsequently changed with CONTROL SET IMAGE, etc. It is important to note that DDT does not release the previous image handle, so it becomes your responsibility to explicitly release the old image handle...

            For example:
            Code:
            CONTROL SEND CBHNDL, Id&, %STM_GETIMAGE, %IMAGE_BITMAP, 0 TO hBmp&
            CONTROL SET IMAGE hDlg&, Id&, NewImage$ ' or use CONTROL SEND...%STM_SETIMAGE, etc.
            DeleteObject hBmp&

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment

            Working...
            X