News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GroupBox Color

Started by IAO, February 06, 2006, 05:24:50 PM

Previous topic - Next topic

IAO

Hi all.
My English is poor. But try.

How do you set the background color of a groupbox?

___xxxx________
|                          |
|                     <----------Change color here.    
|_______________|

Some guide, example, tutorial, any thing...

Thanks.
Bye ('-').
"There is no way to peace. Peace is the way."    Mahatma Gandhi

MichaelW

I'm assuming that you mean to set the background color after the control has been created. I'm not sure this is 100% correct, and I think you will not like the appearance of the group box when the background does not match the window background.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc

    DlgProc       PROTO :DWORD,:DWORD,:DWORD,:DWORD
    GroupBoxProc  PROTO :DWORD,:DWORD,:DWORD,:DWORD

    .data
        hInstance       dd 0
        oldGroupBoxProc dd 0
        hBrush          dd 0
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:

      mov hInstance, rv(GetModuleHandle,NULL)
      call Main
      invoke ExitProcess, eax

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

Main proc
    Dialog "TEST","MS Sans Serif",8,WS_OVERLAPPEDWINDOW,\
            2,5,5,80,60,1024
    DlgGroup "xxx",10,4,60,30,1000
    DlgButton "Set BG",WS_TABSTOP,25,42,30,10,1001
    CallModalDialog hInstance,0,DlgProc,NULL
    ret
Main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

DlgProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

    .IF uMsg == WM_INITDIALOG

      ;-------------------------
      ; Subclass the group box.
      ;-------------------------

      invoke GetDlgItem,hWin,1000
      invoke SetWindowLong,eax,GWL_WNDPROC,GroupBoxProc
      mov oldGroupBoxProc, eax

    .ELSEIF uMsg == WM_COMMAND

      .IF wParam == 1001

        invoke GetStockObject,BLACK_BRUSH
        mov   hBrush, eax

        ;------------------
        ; Force a repaint.
        ;------------------

        invoke GetDlgItem,hWin,1000
        invoke InvalidateRect,eax,NULL,TRUE

      .ENDIF

    .ELSEIF uMsg == WM_CLOSE
       
       invoke EndDialog, hWin, 0

    .ENDIF

    return 0

DlgProc endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

GroupBoxProc proc hCtl:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

    LOCAL hBrushOld :DWORD
    LOCAL hDC       :DWORD
    LOCAL rc        :RECT

    .IF uMsg == WM_ERASEBKGND && hBrush

      ;---------------------------------------------------
      ; To override the class background brush we must
      ; handle all background erase events for the group
      ; box, substituting the new background color.
      ;---------------------------------------------------

      m2m   hDC, wParam
     
      invoke SelectObject,hDC,hBrush

      invoke GetClientRect,hCtl,ADDR rc
      mov   ecx, rc.right
      sub   ecx, rc.left
      add   ecx, 1
      mov   edx, rc.bottom
      sub   edx, rc.top
      add   edx, 1
           
      invoke PatBlt,hDC,rc.left,rc.top,ecx,edx,PATCOPY
           
      invoke SelectObject,hDC,hBrushOld

      ;----------------------------------------------
      ; Bypass the call to the default window proc.
      ;----------------------------------------------

      return 0

    .ENDIF

    invoke CallWindowProc,oldGroupBoxProc,hCtl,uMsg,wParam,lParam
    ret

GroupBoxProc endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start




[attachment deleted by admin]
eschew obfuscation

IAO

Hi all.
My English is poor. But try.

Mr. MichaelW Thanks. I will prove it.


Quote from: MichaelW on February 07, 2006, 10:17:30 AM
I'm assuming that you mean to set the background color after the control has been created. I'm not sure this is 100% correct, and I think you will not like the appearance of the group box when the background does not match the window background.

Is correct.
I have bitmaps(Led's) into  groupbox.
When I change the Windows scheme. Bitmaps are ugly.

When finishes it. I Post here.


Thanks.[/size]
Bye ('-').
"There is no way to peace. Peace is the way."    Mahatma Gandhi

BytePtr

Quote from: IAO on February 07, 2006, 06:18:37 PM
Hi all.
Bitmaps are ugly

If you have for example red groupbox and usual window with standard color then it will also look ugly.
Paint all window to red then.

IAO

Hi all.
My English is poor. But try.


Mr BytePtr:
I need groupbox color grey. Obligatorily for my program. Your option is not valid for me.

Mr. MichaelW:
I try to implement your suggestion. In Win98 OK!. (In other Forum)
But in WinXP,  not  walk  well.
           PUSH 40H
           POP ES
           MOV EBX,8H
           MOV EAX,ES:[EBX]    <--------Here----------OllyDbg Said: Acces violation when reading [00000408]
           MOV NumPort,EAX
           INVOKE SetDlgItemInt,hWin,IDC_EDT1,NumPort,FALSE


I read page 162 of AoA (Dr. Randall HYDE), Addressing modes, and nothing. Read others old Forun, and nain.
I need privileges of Ring0 (Yes or Not ?)
Somebody know where I can read something? (Addressing modes WinXP)
I don't want to abuse of you. But I want to conclude this project.  I want to begin the project of the serial port.


I read your example GroupBoxG.zip. I study it. It's danger for my brain. No .386, .model flat,  no nothing.
You are a Brain Sir. I am Pinky.   I study it.


I post my program here. Please Understand me. Only look it, and help me.
You not do my work. Remember my  English is poor.

Very nice program. I am happy.
Enjoy.


Thanks.
Bye ('-').

[attachment deleted by admin]
"There is no way to peace. Peace is the way."    Mahatma Gandhi

MichaelW

OK, I can see that you are trying to access the BIOS data area and the base I/O address for one of the parallel ports. You cannot do these things from a normal Windows program, even running under Windows 98. To a normal Windows program the BIOS data area does not exist, and most or all of the I/O ports are protected. I'm not sure what you are trying to do here, but if you are going to do it from a Windows program I think you should try to find a way to do it with the Windows API. You might be able to do it using WinIo, but if you access I/O ports that Windows is using you may have reliability problems, with your program and with Windows.

eschew obfuscation

IAO

Hi all.
My English is poor. But try.

Please accept my apologies.
Make comment here:  ;MOV EAX,ES:[EBX]
And the program executes well.
Pardon me.  I am ashamed.
I am sorry I put you to such inconvenience.

WINIO is equal to INPOUT32.DLL.

The Problem is BIOS data area.
If others Windows program can do. My program  also.


Thanks. Bye ('-').
"There is no way to peace. Peace is the way."    Mahatma Gandhi

MichaelW

Sorry, I did not see inpout32.dll in the archive or the line in your source where you loaded it. AFAIK inpout32.dll provides only I/O port access, where WinIo provides I/O port and physical memory access. I posted an include file and import library for WinIo, along with a batch file to build the import library and a test app, here:

http://www.masmforum.com/simple/index.php?topic=3894.0


eschew obfuscation

IAO

Hi all.
My English is poor. But try. :wink


Mr. MichaelW:
Ok. I understand All.

-----------------------------
Single to increase your knowledge.
I will make a program MSDOS in Assembler. This program will create a file.  e.g.(Addr.ini)
I will take the information from this file.
In a Windows program of language C it works well.
------------------------------
When I finish the program. You will have a place there.

You are a Brain. NO! pardon. You are 3 Brain.
Thank you very much by your support.
God blesses to you. Multiplied By Trillion Times.
Thanks == ((Thanks)^Trillion)*Trillion


Thanks. Bye ('_').
"There is no way to peace. Peace is the way."    Mahatma Gandhi