No announcement yet.

Help Needed: Child Windows/SDK style

  • Filter
  • Time
  • Show
Clear All
new posts

  • Help Needed: Child Windows/SDK style

    Three problems:

    Conditions: Using SDK-style programming (i.e., NOT "DDT"), PB/DLL 6.0

    1. I have a progress bar control running as a child control of a regular window - that is, it is not in a dialog.

    I have it working fine, but wanted to change the color of the bar itself. I found the PBM_SETBARCOLOR and PBM_SETBKCOLOR messages, but I cannot find how to specify the color value in lparam.

    When I don't send PBM_SETBARCOLOR, I get the regular blue bar; but whatever I seem to try for lparam for color, I get a black bar.
    (I have two bars: I'd like one yellow and one either green or red.)

    2. I have a dialog box I invoke from the program using the DialogBox API function and a dialog template specified in a resource file. I wanted to know if it's possible to add one of the "standard" icons you might find in a messagebox - like "ICONEXCLAMATION" or "ICONSTOP" to the surface (not in the caption area) of that dialog.

    I could not figure out how to specify a "standard" icon in the resource file, using something like IDI_EXCLAMATION or IDI_ASTERISK; it seems to put it in the resource file I need to have a physical "*.ico" file to define in a ..

    FOO ICON filename.ico
    .. statement.(I also couldn't figure out how to do it as an icon "control" on the dialog without a physical *.ico file).

    3. My application uses a regular window with 13 controls drawn on it. There is no drawing on the "main" window at all. The WM_PAINT processing is simply BeginPaint, EndPaint. I cannot find in any of my books or in my MSDN if I am responsible for re-drawing the controls on this window in response to WM_PAINT (or WM_SIZE). So far, no matter what I do, the controls always appear in the correct place, even after I move other windows over this one, minimize the window, anything. Is this the expected behavior? Or have I just been real real lucky?


    Michael Mattias
    Racine WI USA
    [email protected]
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]

  • #2

    The constants for send color messages for the Progressbar are
    incorrect in the PB Common control include file :

    ' %CCM_FIRST  = 0x2000               ' should already be defined
    ' %CCM_SETBKCOLOR (%CCM_FIRST + 1)   ' should already be defined
    '        %PBM_SETBARCOLOR        = (%WM_USER+6)  ' wrong
    '        %PBM_SETBKCOLOR         = (%WM_USER+7)  ' wrong
    %PBM_SETRANGE32         = (%WM_USER+8)
    %PBM_SETBARCOLOR        = (%WM_USER+9)           ' correct
    %PBM_SETBKCOLOR         =  %CCM_SETBKCOLOR       ' correct

    Chris Boss
    Computer Workshop
    Developer of "EZGUI"


    • #3
      Michael --
      hIcon = LoadIcon(ByVal 0&, ByVal %IDI_...)
      DrawIcon hDC, X, Y, hIcon (or DrawIconEx)
      Depends of situation. If you have standart controls, you don't need to worry:
      childs receive WM_PAINT also and redraw itself.

      E-MAIL: [email protected]


      • #4
        The color value for lparam is a dword. Search your Win32 Help file
        for COLORREF for an explanation.

        Bernard Ertl
        Bernard Ertl
        InterPlan Systems


        • #5
              wParam = 0;
              lParam = (LPARAM)(COLORREF)clrBar;
          Sets the color of the progress indicator bar in the progress bar control. 
          ·	Returns the previous progress indicator bar color, or CLR_DEFAULT if the progress indicator bar color is the default color. 
          COLORREF value that specifies the new progress indicator bar color. Specify the CLR_DEFAULT value to cause the progress bar to use its default progress indicator bar color. 
          The COLORREF value is a 32-bit value used to specify an RGB color. 
          When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form: 
          The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.


          [This message has been edited by Cecil Williams (edited February 27, 2001).]


          • #6
            Thnaks for the answers, guys, which were...

            PBM_SETBARCOLOR can use the RGB macro for the color:

            SendDlgItemMessage hWnd, %IDC_PROGRESS_MAP, %PBM_SETBARCOLOR, 0, RGB(255,0,0)  ' red
            SendDlgItemMessage hWnd, %IDC_PROGRESS_SCAN, %PBM_SETBARCOLOR, 0, RGB(255,255,0) ' yellow
            (It also insists that the RGB color be in lparam, not wparam where I had been putting it).(duh!).

            Good to know Windows handles the re-painting of child controls; I still cannot find that in print, but what the heck, it works OK.

            I played with DrawIcon a little while, but could not get it to work; however, reading the doc I know it will work if I really want it to.


            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]


            • #7
              Originally posted by Michael Mattias:
              I played with DrawIcon a little while, but could not get it to work; however, reading the doc I know it will work if I really want it to.
                 #Compile Exe
                 #Register None
                 #Dim All
                 #Include "WIN32API.INC"
                 Function MainWndProc(ByVal hWnd As Dword, ByVal wMsg As Dword,_
                    ByVal wParam As Dword, ByVal lParam As Dword) Export As Long
                    Select Case wMsg
                    Case %WM_DESTROY: PostQuitMessage 0: Exit Function
                    Case %WM_PAINT
                       Dim ps As PAINTSTRUCT
                       BeginPaint hWnd, ps
                       DrawIconEx ps.hDC, 10, 10, LoadIcon(0, ByVal %IDI_ASTERISK), 64, 64, 0, ByVal 0, %DI_Normal
                       DrawIcon ps.hDC, 70, 70, LoadIcon(0, ByVal %IDI_EXCLAMATION)
                       EndPaint hWnd, ps
                    End Select
                    Function = DefWindowProc(hWnd, wMsg, wParam, lParam) 'performs default processing of message
                 End Function
                 Function PbMain
                    Local Msg As tagMsg, wClass As WndClassEx, hWnd As Dword, szClassName As Asciiz * 9
                    szClassName = "BtnLook"
                    wClass.cbSize = SizeOf(wClass)
                    wClass.hInstance = GetModuleHandle(ByVal 0&)
                    wClass.lpszClassName = VarPtr(szClassName)
                    wClass.lpfnWndProc = CodePtr(MainWndProc)
                    wClass.hbrBackground = GetStockObject(%WHITE_BRUSH)
                    wclass.hCursor       = LoadCursor(ByVal 0&, ByVal %IDC_ARROW )
                    RegisterClassEx wClass
                    hWnd = CreateWindow (szClassName, "Test", %WS_OVERLAPPEDWINDOW, _
                        10, 10, 240, 180, %NULL, %NULL, wClass.hInstance, %NULL)
                   ShowWindow hWnd, %SW_SHOW
                   UpdateWindow hWnd
                   While GetMessage(Msg, %NULL, 0, 0)
                      If IsDialogMessage (hWnd, msg) Then
                         TranslateMessage Msg
                         DispatchMessage Msg
                      End If
                   Function = Msg.wParam
                End Function

              E-MAIL: [email protected]