mIRC Homepage
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
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.
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.
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.
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.
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.
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.
© mIRC Discussion Forums