|
hi,
How is it possible to change the color of a Button
|
|
|
|
|
Subclass teh button then you can handle the WM_CTLCOLORBTN message. In this message you will set the color of the brush that you want the button to use instead of the default color.
|
|
|
|
|
I done that method also...But I didn't get the color
|
|
|
|
|
You need to create a brush as a member object and return it from this function.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
kilowatt wrote:
Subclass teh button then you can handle the WM_CTLCOLORBTN message
Only owner drawn buttons receive this message.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Check out the following URL
Chris's and subclassing buttons
Very imformative!!
Laterz !;P
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I have a resizabe dialog, now how do I restrict the minimum size when manually resizing.
Thanks
-----------
|
|
|
|
|
You should check out the WM_GETMINMAXINFO message in MSDN.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Cool I did not know of this until now...I would have just handled the OnSize...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
Given the window handle of a window in another app, how to get the processID and thread ID related to that Window? E.g. When we SPY++ a window, it'll show the processID and threadID under the window.
Thanks in advence,
Wally
|
|
|
|
|
::GetWindowThreadProcessID
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
ok let me see if I can articulate my problem. If I don't let me know.
I have a class called clientsocket that Is a derived from CAsyncSocket. I've overridden OnReceive to just put a AfxMessageBox on the screen when it is triggered.
ok heres the problem.
When I create the listening socket and accept the connection from inside a thread the OnReceive never triggers. I can send messages from the server to client but never get the Onreceive when sending something from the client to the server. The part that I can't figure out is that if I cut and paste the exact same code into a method that is called by a button on the main dialog window it works correctly. just not when I put the code in a thread... does this make sense? if not let me know and I can try to elaborate.
|
|
|
|
|
How do you know the routine isn't getting called? Have you set a breakpoint in the routine?
If you are just going by the lack of a message box, then maybe it is caused by trying to access windows in another thread and thus failing.
Instead of calling AfxMessageBox from a worker thread, just try ::MessageBox (NULL, "Made it", "Made it", MB_OK);
But these are all guesses.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
I thought about that and added a break point put it doesn't break so I assume it never gets in there.
anybody that wants a copy of the code let me know and I can send it to them...its small...about 35k.
|
|
|
|
|
I just read somewhere that its bad to try to use a CSocket in a workerthread because of a lack of a message pump. could this possibly be my problem...theres nothing in there to handle the OnReceive?
|
|
|
|
|
I think it should be okay in a separate thread. I have written exactly the same code in the past, where I derived a class from CAsyncSocket and ran it in a separate thread without any problems. (For the thread, I derived a class from CWinThread)
At the risk of stating the obvious, you did do an AsyncSelect( FD_READ|.... ) at some point, to enable the ::OnReceive virtual function.
I can have a (quick, as I don't have much spare time) look at your code if you like.
Dharminder S. Birdi
|
|
|
|
|
hello -- i am trying to use both isalpha() or isdigit() in my code and they aren't working. I have the following code
next_state WhatIs( char chrSymb )
{
if (isdigit(chrSymb)) return digit;
if (isalpha(chrSymb)) return letter;
if (chrSymb == '_') return underscore;
else return not_char;
}
I continually get 'not_char' from this. I am afraid it is that I am sending a char into an int argument. Here is how I call the function.
input = WhatIs( MyString[i] ); where MyString is a string from the STL. When I try to step into this function I get a prompt to "Enter the path for _CTYPE.C" In my header I include:
#include <ctype.h>
Any ideas what I am doing wrong?
thanks,
tim
---------------------------------------
Tim Booher
|
|
|
|
|
Well, on most systems, a char is a signed number from -128 to 127. Considering that the characters you are trying to test are in range of 0-127, you shouldn't be having a problem.
As far as the prompt for _CTYPE.C, you must not have installed the CRT source when you installed the compiler (God I LOOOOOVE having the CRT source.)
What are you doing wrong? I don't know. What is the value of chrSymb when it is failing?
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Hi,
I'm working on a multi-view application and I'm trying to change the mouse cursor when it is moved over one of the views.
I've got the following code in the view:
BOOL CTheView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(m_mouseCursor)));
return TRUE; //Handled
}
I'm doing it this way since I've disabled the class cursor with:
::SetClassLong(this->GetSafeHwnd(), GCL_HCURSOR, NULL);
and initialised the m_mouseCursor attribute with the appropriate system cursor type. [This appears to work since a later attempt to GetClassLong(GCL_HCURSOR) returns NULL.]
However, when I drag the mouse over the view, I get the required cursor flickering with the standard mouse cursor. When the mouse stops moving, the standard mouse cursor is the one displayed. This eliminates the cause being an incorrect cursor id, since the correct cursor actually appears, but overwritten shortly after.
I suspect the problem to be due to the fact that I have a number of views in my application, but the cause is unfortunately not clear.
If anyone can shed any light on this, your help will be much appreciated.
|
|
|
|
|
My first guess is you're calling the global scope SetCursor function and you need to call the one that is a member of your window. Remove the :: and see what happens.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Thanks Christian,
It wasnt that. It turned out to be a silly error. Another place in the code was calling BeginWaitCursor() EndWaitCursor(). Turns out EndWaitCursor() simply resets the cursor to the standard arrow cursor, not to the previous cursor as would be logical.
|
|
|
|
|
I find the step through function useless in Visual C++ because it always takes you into the machine code -- I find this very cool, but I can't follow the execution of my program because it takes me through so many details. In visual basic I step through the code all the time, because I can watch what happens. Is there any way to set up my debugger so it just steps through _my_ code and doesn't go into all the library files?
I would be very happy if you can help me . . .
tim;)
---------------------------------------
Tim Booher
|
|
|
|
|
It steps into the library files where the source is not available ( such as API calls ), just use shift-F11 to step out again when it does that.
The excellent 'Debugging Windows' book by John Robbins covers enough asm to help you start finding the asm output useful. So they tell me, I never had time to make head nor tails of it
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Thanks -- that is a lot more helpful, but what do you mean by (the source is not available) if the source were not available -- then how could the debugger step into the the source.
cheers,
Tim
---------------------------------------
Tim Booher
|
|
|
|