mIRC Home    About    Download    Register    News    Help

Print Thread
How to make my DLL change control's properties #11969 19/02/03 11:44 AM
Joined: Feb 2003
Posts: 8
N
netgert Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Feb 2003
Posts: 8
Hi,
I need to make a DLL which will change the text and background of a control. The dialog's handle, controls id and the color is passed to the DLL and parsed correctly, but calling the SetTextColor (from Windows API) has no function, same with SendMessage. Why doesn't it work? I can get the correct properties, but why can't I set them??? I'm using Delphi as the programming language, but can understand C/C++ or VisualBasic too. Please help ASAP

Re: How to make my DLL change control's properties #11970 19/02/03 02:21 PM
Joined: Dec 2002
Posts: 87
V
vcv Offline
Babel fish
Offline
Babel fish
V
Joined: Dec 2002
Posts: 87
That's not how you change colors of a dialong control.

You have to handle the proper WM_CTLCOLORBTN/WM_CTLCOLORDLG/WM_CTLCOLOREDIT/WM_CTLCOLORLISTBOX/WM_CTLCOLORSTATICWM_CTLCOLORSCROLLBAR message to set the color.

Re: How to make my DLL change control's properties #11971 19/02/03 08:17 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
That will likely have no effect at all. Reading MSDN:

The WM_CTLCOLORBTN message is sent to the parent window of a button before drawing the button. The parent window can change the button's text and background colors. However, only owner-drawn buttons respond to the parent window processing this message.

Note the "owner-drawn buttons", the buttons in mIRC, to my knowledge, are not owner drawn. So that means they would ignore this. What you likely need to do is get the DC of the control and modify it like that.

Re: How to make my DLL change control's properties #11972 19/02/03 08:29 PM
Joined: Dec 2002
Posts: 87
V
vcv Offline
Babel fish
Offline
Babel fish
V
Joined: Dec 2002
Posts: 87
Read further, and you'll find that is only true for buttons, and I think listbox's. Static controls do not need to be owner-drawn to process that message, I guarantee that.

Re: How to make my DLL change control's properties #11973 20/02/03 01:00 PM
Joined: Feb 2003
Posts: 8
N
netgert Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Feb 2003
Posts: 8
But what's the use for SetTextColor and SetBkColor. They're not marked as obsolote. They should send the message to the control to change the color. It is a bad idea to check for that control's type and then send the right message. Why does it all have to be so complicated? Also some other messages, like WM_ENABLE(D - ?) with 0 value does not disable the control. And are all control ID's 6000 + ID in script??? Like when in script my button control ID is 1 then actually it is 6001. Khaled should write developers documentation.

Re: How to make my DLL change control's properties #11974 20/02/03 02:14 PM
Joined: Dec 2002
Posts: 87
V
vcv Offline
Babel fish
Offline
Babel fish
V
Joined: Dec 2002
Posts: 87
They're used for setting the current working colors of a DC (Device Context). use SetTextColor on a DC, then DrawText, and you will see what I mean.

It is NOT used to change the colors of a control.

Re: How to make my DLL change control's properties #11975 20/02/03 06:28 PM
Joined: Dec 2002
Posts: 89
N
Necroman Offline
Babel fish
Offline
Babel fish
N
Joined: Dec 2002
Posts: 89
Khaled is unlikely to write any documentation for developers, as it would bound him to maintain a kind of backward compatibility. He's been using the "6000+id" formula for long, but you aren't getting any guarantees.

Don't wonder why, otherwise you'll probably receive a bunch of "mIRC's his baby" arguments. We are to accept the current state of things. My advice is to taylor your application to a specific version of mIRC. If things change, you'll have to update your application.

Of course it means you can't develop anything serious for mIRC.


Sincerely,
Necroman, #mIRC @ Undernet