can i make a custom button for VC++ MFC
like use a picture as a button.
can i make a custom button for VC++ MFC
like use a picture as a button.
You coud define a RECT and blt (whichever blt method you prefer) your button pic there. Then on WM_LBUTTONDOWN assign the current mouse coord's to a POINT and if the user clicks, use PtInRect to check to see if they clicked on your button. To add "realism" to it, you can have a pic of multiple stages of your button. So for instance when the mouse moves over your button but they haven't clicked, a highlighted button pic will be displayed (reset if the mouse isn't over the button), and another pic to blt when they click to show a "pushed" state.
wa
thats chim
is there any webby that can help in that ?????
or is there any guide to do that ?
What's "chim"?thats chim
Let me know what part you don't understand and I'll go into more detail.
becoz i dont even know how to create a button
im using the MFC all the way
so i dunno how to create a custom on
I haven't messed with MFC very much, but here's a way to create a simple button:
This will create a standard Window's push button.Code://in your global declares HWND Btn1=NULL; //in your message handler //Create the Button //in this case "hwnd" is the HWND param passed to your //message handler, and "hInstMain" is the hInstance of your //parent window. case WM_CREATE: Btn1=CreateWindow(0,"Button","Button 1",WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,10,10,100,30,hwnd,NULL, hInstMain,NULL); //See if the button was pushed case WM_COMMAND: if((HWND)lParam==Btn1) { //your function goes here }
To do it the
way that I described earlier, you would define a RECT that would
cover the area that your button covers. Then in your message
handler check for cursor movement (WM_MOUSEMOVE). Then use
the cursor coords ((LOWORD)lParam=x,(HIWORD)lParam=y) and
put these into your POINT structure. Then use PtInRect to see if
the POINT structure is within the RECT structure. If so, highlight
the button.
To check for mouse clicks use the same method except instead
of checking with WM_MOUSEMOVE you'd check with
WM_LBUTTONDOWN, etc..
Also a non MFC jockey, but I do know MFC provides a CBitmapButton class which may well do what you want.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Thanks for the back-up, Adrian.
:: hides in shame at my lack of MFC knowledge ::
monkeymon, sorry if my examples don't help. As I said I have
very little experience with MFC. If either of my examples aren't
what you're looking for I'll search for some good MFC
CBitmapButton tutorials/articles and post the links.
>>> :: hides in shame at my lack of MFC knowledge ::
Nothing to be ashamed of. I bought Jeff Prosise's MFC bible as a little gift to myself the Christmas before last, and have read the first three chapters!
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
is the book gd ???Originally posted by adrianxw
>>> :: hides in shame at my lack of MFC knowledge ::
Nothing to be ashamed of. I bought Jeff Prosise's MFC bible as a little gift to myself the Christmas before last, and have read the first three chapters!
becoz i have bought the microsoft's one but not very good.
can i have the title of your book, so i can make a search at my school libery
It is supposedly the definitive work, but it is an MS book. "Programming Windows with MFC" make sure you have the second edition.
http://www.amazon.co.uk/exec/obidos/...530542-7359833
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
I recently finished that book and I liked it alot. Although I dont think it is a great book if you are a beginer in Mfc. I would rather recomend "Teach yourself VC++ in 21 days" because in that book you write apps from the first page. The Prosise's book is the true Mfc bible and it is open on my desk 90% of the time I program, a great reference.