|
any idea, how to set the colour of text for an edit box. Say from black to blue.
Kind Regards
Caoimh
|
|
|
|
|
You'll need to override the WM_CTLCOLOR message via CWnd::OnCtlColor()'s handler function. You can then set the colour of the edit (or static) controls of your program.
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch(nCtlColor)
{
case CTLCOLOR_EDIT:
{
pDC->SetTextColor(RGB(0, 0, 255));
pDC->SetBkMode(TRANSPARENT);
}
break;
default:
break;
}
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
I Dream of Absolute Zero
|
|
|
|
|
I have a question in regard to your post. I'm sure there is a way I just can't figure it out. How do you set an individual edit box's background color instead of CTLCOLOR_EDIT where it changes all the edit controls? Secondly I can't get the code you posted to actually work. I changed a few things to get it to work.
<b>HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_EDIT || nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(100,190,199));
HBRUSH B = CreateSolidBrush(RGB(2,2,255));
return (HBRUSH) B;
}
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}</b>
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
Firstly, looking at the code that you've posted, I suspect the reason why it now suddenly works is because your control is a regular static window (used for read-only text disply etc) and not an edit control, as was assumed. I tend to use a switch statement to distinguish between the control types (there are other types such as CTLCOLOR_DLG and CTLCOLOR_LISTBOX)
Secondly, you can target a specific control by quering its control id. For Example:
if(pWnd->GetDlgCtrlID() == IDC_EDIT_INPUT)
{
pDC->SetTextColor(RGB(0,190,0));
pDC->SetBkMode(TRANSPARENT);
}
I Dream of Absolute Zero
|
|
|
|
|
I have an application where I have a dialog item with a button.
All I want to do is disable the button after the user selects it, so it cant be selected again until later in the program. I know this is easy...I forgot how to do it.
I thought is was something like:
pButton->Enable("false");
Jerry
|
|
|
|
|
|
pButton->EnableWindow(0);
|
|
|
|
|
if you have a button control variable called say btn_mybutton;
do this
btn_mybutton.EnableWindow(FALSE); //this will disable it
btn_mybutton.EnableWindow(TRUE); // this will enable it
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
I have an application that opens a document over dde in winword. Another .Net application can open documents with ODMA(Open Document Management). If i open a document in word with ODMA and i close word, and then i want to open a document from the other application then DDEConnect stops and waits until i close the application that opened the document with ODMA and i start a new word.
It's a bit complicated. Maybe someone has seen a DDEConnect to stop, and wait for something. Why can it be? Please help me!!!
|
|
|
|
|
Just wondering how one can determine if a int is even or odd?
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
int i=2;
int j=3;
i%2 = 0
j%3 = 1
You figure out the rest
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
j%3 = 1 ?? j%2 = 1
Ok, this could be faster,
i&1 = 0 j&1 = 1
but compiler would probably optimize your
solution to this anyway :
rrrado
|
|
|
|
|
I think there was a typo in the other post.
Anyway, mod it with 2 and you'll either get back 1 or 0. For instance:
1 % 2 = 1
2 % 2 = 0
3 % 2 = 1
... and so on. E.g.,
bool IsEven(int j)
{
if(j % 2 == 1)
return false;
else
return true;
}
This could certainly be optimised if high performance is needed... I just posted a simple version.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
Hi, I am trying to make an installer for my app. Id like to have all data(files) in one exe file. How should I append or insert these files to my installer application and how to aproach them?
Thanks.
|
|
|
|
|
Instead why dont you import the files as custom resource into your installer, then at installation use the resource handling functions to load and write it to the harddisk.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Thx, but what are these resource handing function?
|
|
|
|
|
To start with...
LoadResource(...);
LockResource(...);
SieofResource(...);
I dont have a sample, try looking for these apis may be you will get one.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
You can do it, as the other poster said, by shoving your files into resources in your EXE.
You might be better off getting a commercial package that creates self-extracting ZIP files (I think WinZip can do this but I'm not sure. I know there are others.)
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
I have 32 bit uncompressed bitmap stored in my application's resources.
I need to load this 32bit bitmap's data for some processing, before it
will be displayed to user.
I'm using GetBitmapBits().
This is working perfectly, but only when my screen is set to display 32 bit colors.
When I switch system's display mode to 16 - bit, this function is not working as expected - it's giving me 16 bit bitmap data.
How to get bitmap's data always in 32 bit ?
Maybe GetDIBits() could do this, but I don't know which DC to use as
first parameter.
Any ideas please ?
Thanks !
rrrado
|
|
|
|
|
Hmm..
Bitmaps are usually selected into a device context, and generally, you create a device context that represents the current display. The best way to alter this behaviour is to manually create a DC large enough to hold your bitmap, and with the correct color depth. Then, you can select this bitmap into a device context and use the device context's functions to retrieve the color of each pixel. The problem with GetBitmapBits is that it creates a screen-compatible DC to which the bitmap is selected, and bases it's results into the return values of pixel query on the DC surface. Thus, if the DC is set to 16-bit depth, the resulting bit array consists of 16-bit data.
I'm not sure, but the DC parameter of GetDIBits represents a device context into which the device dependant bitmap is to be selected. The best way to proceed would be to create arbitary device contextes with different color depths, and see how the resulting bitmap bits vary.
The easiest way, of course, is to force the display to 32-bit depth before doing the loading: just put a 32-bit screen depth as a prerequisite for your application.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks for answer,
but application must run also on 256 color displays,
The problem is that I don't know how to create 32 bit DC manually,
without 32 bit display colors. Maybe it's not possible.
In worst case I'll have to store bitmap data as raw data in resources
rrrado
|
|
|
|
|
Hi,
does anyone know of debuggers available which were programmed using MFC's. It would be of some use as I need to know how to display a disassembly file
Kind regards
Caoimh
|
|
|
|
|
|
let me put the question diferently.
I've an assembly file and I want to display the disassembly file of this to a mfc application. How would this be done??
|
|
|
|