-
Oct 31st, 2001, 09:29 AM
#1
Thread Starter
Hyperactive Member
CreateSolidBrush & GetStockObject
I am trying to set the background of an edit control... i know u have to handle the WM_CTLCOLOREDIT which is fine and i can set the back and fore color like this
Code:
case WM_CTLCOLOREDIT:
if(IDC_TEXT == GetDlgCtrlID((HWND)lParam))
{
SetBkMode((HDC)wParam, TRANSPARENT);
SetTextColor((HDC)wParam, RGB(59, 195, 25));
return (LRESULT)GetStockObject(BLACK_BRUSH);
}
break;
this works fine, but i would like to create create my own brush using CreateSolidBrush and setting the RGB color value.. i'm attempting to call the code like this
Code:
case WM_CTLCOLOREDIT:
if(IDC_TEXT == GetDlgCtrlID((HWND)lParam))
{
hbrush = CreateSolidBrush(RGB(0, 0, 0));
SetBkMode((HDC)wParam, TRANSPARENT);
SetTextColor((HDC)wParam, RGB(59, 195, 25));
return (LRESULT)GetStockObject(hbrush);
}
break;
i get an error when i try and compile... the error is
"error C2664: 'GetStockObject' : cannot convert parameter 1 from 'struct HBRUSH__ *' to 'int'"
how to i fix this ??
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 09:36 AM
#2
transcendental analytic
hbrush has to be a HBRUSH
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 31st, 2001, 09:40 AM
#3
Thread Starter
Hyperactive Member
umm why, u only use that to define hbrush... I've already defined hbrush as
HBRUSH hbrush;
its just not in the code, its defined as global..
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 10:33 AM
#4
GetStockObject takes long integers for an argument not structs.
HBRUSH is a struct. I think that's what Kedaman is saying.
-
Oct 31st, 2001, 11:18 AM
#5
Thread Starter
Hyperactive Member
ok, so how do i fix this ??? and i also have another problem... for some reason when i set the back and forecolor and type some text and then attempt to delete it by hitting backspace, it doesn't delete until the i minimize the window and restore it... i tried catching the en_change message and sending an updatewindow but it didn't work.... how do i fix this also ?? the reason i need to create my own brush is because i open the color dialog box for the user to select the back and forecolor of the edit control...
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 11:39 AM
#6
transcendental analytic
well at least the type convertion you can do:
return (LRESULT)GetStockObject(*(int*)(void*)&BLACK_BRUSH);
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 31st, 2001, 01:47 PM
#7
Thread Starter
Hyperactive Member
believe or not i had already tried that with no luck... it compiles just fine but doesn't work
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 01:54 PM
#8
Thread Starter
Hyperactive Member
ok i figured out how to create my own brush and use it for the background of my edit control now i have another problem.. the problem is refreshing the edit control... the new color doesn't display until i minimize the edit control and restore it... wierd
i've tried updatewindow with no luck
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 01:57 PM
#9
transcendental analytic
does the rest of your window update at all? maybe you want to show us the callback proc
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 31st, 2001, 02:02 PM
#10
Thread Starter
Hyperactive Member
ok i fixed the update of the background by calling invalidate rect so now that works... now i need to make sure that the window gets updated properly when text gets added and deleted from tthe edit control
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 02:07 PM
#11
Thread Starter
Hyperactive Member
ok nevermind i got it i just simply handle the en_change event and invalidaterect works perfect thanx for your time tho..
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 04:14 PM
#12
Thread Starter
Hyperactive Member
ok new problem!! LOL instead of handling the EN_CHANGE, i now handle the EN_UPDATE... works perfect when deleting text... the problem i now have is with scrolling... how do i detect when a user scrolls ?? and i don't mean EN_VSCROLL or EN_HSCROLL those messages only fire when a scrollbar button is clicked and not the actual scrollbar or when its scolling... any suggestions ?? perhaps not handling EN_UPDATE or possibly some other message.. would WM_PAINT work in this situation ??
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 04:42 PM
#13
Thread Starter
Hyperactive Member
nevermind.... i've figured it out... in case anybody reads this and is wondering what to do here it is.. u don't have to handle any paint messages....
simply do the code like this
Code:
case WM_CTLCOLOREDIT:
if(HWND_TEXT == GetDlgCtrlID((HWND)lParam))
{
HRBUSH hbrush = CreateSolidBrush(RGB(0,0,0)); //create a solid black brush
SetBkColor((HDC)wParam, RGB(0,0,0)); //Set Background to Black
SetTextColor((HDC)wParam, RGB(255,255,255));//Set TextColor To White
return (DWORD)hbrush; // brush must be returned to update
}
break;
just note that if u want to change the background, u must change the hbrush RGB as well as the RGB in the SetBkColor..
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 04:50 PM
#14
This is great - post once, watch you ask/solve several questions.
-
Oct 31st, 2001, 05:11 PM
#15
Thread Starter
Hyperactive Member
LOL!! yea i was pretty much talking to myself those last few posts!! AHAHAH it helps to talk it out sometimes!! LOL
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Oct 31st, 2001, 06:40 PM
#16
transcendental analytic
Hehe, wonderfull to read these
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 28th, 2021, 10:24 AM
#17
Re: CreateSolidBrush & GetStockObject
-
Mar 28th, 2021, 12:11 PM
#18
Re: CreateSolidBrush & GetStockObject
Originally Posted by xiaoyao
how to use by vb6
This thread is 20 years.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|