|
ok....tis a long story.....here goes......
u c.....the code.....
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR1 );<br />
SetCursor( hIcon );<br />
return TRUE;
is a working code coz i have put this in my Dialog based application (Xyz) in a class called CXyzDlg..... that is, i have already added this function "OnSetCursor()".....and the cursor changes......in the main Dlg box but..... i have derived a class from the CStatic Class named it as "CMyClass".....and i have created obcts of it in the CXyzDlg class.....basically these objects i have created by placing the "static control" on the dialog box and then..... thru the class wizard created an object linking it with the picture control of type CMyClass(that is .....SUBCLASSING).....
also in thiz CMyClass i have added the "OnSetCursor()" function as well......and many other mouse functions like "OnMouseMove()","LbuttonDown()".....etc.....but here when i put in the same code as i had put in the main Dlg box for the "OnsetCursor()".....it does not change!!!!!......y???
heres the code......that i have put in the derived class CMyClass......
<br />
#include "stdafx.h"<br />
#include "creamz.h"<br />
#include "MyClass.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
CMyClass::CMyClass()<br />
{<br />
m_DragOn1=FALSE;<br />
m_pot1=0;<br />
m_update=TRUE;<br />
}<br />
<br />
CMyClass::~CMyClass()<br />
{<br />
}<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CMyClass, CStatic)<br />
ON_WM_LBUTTONDOWN()<br />
ON_WM_LBUTTONUP()<br />
ON_WM_MOUSEMOVE()<br />
ON_WM_SETCURSOR()<br />
END_MESSAGE_MAP()<br />
<br />
<br />
void CMyClass::OnLButtonDown(UINT nFlags, CPoint point) <br />
{<br />
<br />
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR2 );<br />
SetCursor( hIcon );<br />
m_DragOn1=TRUE;<br />
<br />
<br />
CStatic::OnLButtonDown(nFlags, point);<br />
}<br />
<br />
void CMyClass::OnLButtonUp(UINT nFlags, CPoint point) <br />
{<br />
<br />
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR1 );<br />
SetCursor( hIcon );<br />
m_DragOn1=FALSE;<br />
<br />
<br />
CStatic::OnLButtonUp(nFlags, point);<br />
}<br />
<br />
void CMyClass::OnMouseMove(UINT nFlags, CPoint point) <br />
{<br />
<br />
<br />
if(m_DragOn1==TRUE)<br />
{<br />
<br />
if(m_pot1<62)<br />
m_pot1+=1;<br />
else<br />
m_pot1=0;<br />
<br />
if(m_pot1%2==0)<br />
m_update=TRUE;<br />
<br />
}
<br />
<br />
<br />
<br />
CStatic::OnMouseMove(nFlags, point);<br />
}<br />
<br />
BOOL CMyClass::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) <br />
{<br />
<br />
if(m_DragOn1==FALSE)<br />
{<br />
<br />
<br />
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR1 );<br />
SetCursor( hIcon );<br />
}<br />
else<br />
{<br />
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR2 );<br />
SetCursor( hIcon );<br />
} <br />
<br />
<br />
return TRUE;<br />
<br />
<br />
}
plz help me out......
thanx in advance.....and thanx for ur intrest!!!!!
|
|
|
|
|
I'm actually working with MFC for a long time..
But I've still been thinking I have so many things to study about MFC..
furthermore,, I wanna reorganize my MFC knowledge.
How can I restart again?
Which part of framework is the most significant in MFC do you think?
I've just digging into source code about MFC Message Map framework...
Is that good choice..
How can i make feel so satisfied about MFC, then can say I'm so perfect MFC programmer?
Thanks in advance...
|
|
|
|
|
(1) Doc/View shows to many tradeoffs. If your project does not fit the proposed model exactly, forget it, don't use it.
(I wouldn't go as far as to say it is seriously hosed, but only because I'm feeling nice and cheery today.)
(2) Learn Win32 API (I think this is still a valuable trait). Win32 is a fairly flat interface (99% of the time you will use 1% of the API), so the basics are easy to understand. don't bother with window creation to much, it's a bit trickier than the rest.
(3) See how MFC "wraps" this - e.g. how CWnd relates to a HWND (If you ask me, they should have used smart pointers[^] )
(4) Write a Doc/View Framework that is really usable! (evil snicker)
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
You are a brave person, I am satisfied by the thread posted by you, because i was thinking i am the only one with same problems.
I am using VC (MFC) for one year, while remaining away from its internal details. I think that MFC is a kind of thing that no body in the universe knows all (may be), and it also requires a kind of U turns (smaller or larger) again and again, i.e. going back and learning/reading again is always needed.
After doing some larger projects in MFC I am also thinking now a days to study Message Maps (surprisingly same as you) in detail, because it is the main thing in event driven programming, but going into the deepest details code/implementation upto WINMAIN is impossible for me at this stage that is too difficult for me.
Satisfaction/Recognition. I think if we do a project successfully in MFC, then it is automatically a satisfaction/recognition for the extent of MFC used in project.
Which part of framework is the most significant in MFC do you think?
I think you have choosen right one.
Question?
People often say to study windows programming before or along with MFC,
and recommend books such as "windows programming by petzold"
1. Is it necessary to study windows programming before or along with MFC,why yes, why not ?
2. If yes then please tell the above book is good one or not (I haven't seen it) please recommend some good books/ resources?
Thanks in Advance.
|
|
|
|
|
I also have troubles on study VC++, but frankly speaking. My programming study was begin with MFC, when I just familar with the basic of C++, my elder classmate who are good at programming told me--"you can just look the chapter MFC, and jump over the windows API." I don't know why. but I really found it's useful, I used very little time and make out a project about communication. I was so exciting. but then I was stoped studying, I fell it's hard for me to improved my programming skills, my base was not solid, so I have meet many troubles on the further studying of programming.
Then I come back to study API and do some simple projects. maybe it's useless but it's useful for further studying, especial used with MFC, so I think the one who wanna study VC++ programming can started with MFC and then come back to study API,haha..
I never heared about the books named "windows programming by petzold".
--==There is No Poverty Like Poverty of Spirit!==--
|
|
|
|
|
dada_buley wrote:
I never heared about the books named "windows programming by petzold".
You have never heard of the one book on programming Windows that every experinced Windows programmer has reccommend as a must have book, since it first came out. MFC is a frame work to simplify the creation of user interfaces and that is about all it is. To fully understand what the frame work is doing you need to have a fairly good understanding of the API and that is where this book comes in. In many ways MFC makes it easy to create an application with very little understanding of whats going on, but when things do go wrong (and they will), having an understanding of the API and how it works becomes essential.
By the way MFC is not the only frame work for programming Windows, it is just the one that the majority of Windows programmers use.
INTP
|
|
|
|
|
Alright...
I'm just happy about your opinions..
pc_dev wrote:
I think that MFC is a kind of thing that no body in the universe knows all (may be)
That's exactly what I'm thinking..
But MFC teams might knows all of them, I suppose
Anyway, I'm gonna study over and over again.. if I can
Thanks. all..
|
|
|
|
|
MFC Internals by Shepherd Wingo...
That and look at the source code...
By the way the MFC 7.1 IS better...
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
Is there a way to get notified about system shutdown or restart?
In which way will an application be terminated when shutting down?
|
|
|
|
|
There are two Way for Knowing System is Shutting Down
First Easy Way
When ever system shutdown ,it send WM_QUERYENDSESSION all opened Application notifying system is shuting down.
Second Little tough way
Write a WinLogon Notification package,that will notify you about System Shutdown and much more.
you can Find a Very Good article on CP MFC/C++ /SYSTEM section over Winlogon DLL
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
WM_QUERYENDSESSION seems perfectly fitting for me.
Thanks, Alok
|
|
|
|
|
Is there a way to trap certain keystrokes from an application, even though its window does not have the focus?
My goal is to make an application almost totally invisible (except in Windows Task Manager), i.e. the main window is hidden, task bar button removed, Alt-Tab does not show it - but somehow I have to activate it from time to time, i.e. I need a kind of shortcut.
|
|
|
|
|
Let i take your goal one by one.
Vancouver wrote:
My goal is to make an application almost totally invisible (except in Windows Task Manager)i.e. the main window is hidden, task bar button removed, Alt-Tab does not show it
Make a Dialog Box application with WS_EX_TOOLWINDOW Style (that remove button from taskbar and doesn't respond to ALT+tab message)
and Start your window in hidden mode.
Vancouver wrote:
but somehow I have to activate it from time to time, i.e. I need a kind of shortcut.
u can use HOTKEY for that when ever a special key combination occur activate the window (look for RegisterHotKey api in MSDN)
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Making the window invisible was not a problem, but thanks anyway. Btw, you don't need WS_EX_TOOLWINDOW while the window is hidden, for the task bar button disappears, and the application does not come up with Alt-Tab (even the task manager does not show it as an application, only as a process). However, you need WS_EX_TOOLWINDOW if you want the task bar button disappear, etc. even while the window has the focus.
Re HOTKEY: this gave me the hint, and I looked for it (earlier I was looking for "shortcut" and did not find anything useful).
I found an alternative solution too: WM_SETHOTKEY. I will evaluate, which way is better for the particular situation.
Thanks, Alok.
|
|
|
|
|
Yeah , may be interpreted your problem Wrong.
Sorry and Thanks
By the Way the Name is 'ALOK' not Alek
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I created a Windows Form, and would like to use it as a template. How can I do this. If I save it under a new name funny thing happen. I am using Visual Studio 6. I setup a project using C++ and Windows Forms.
|
|
|
|
|
Hi,
I have implemented a game that adds nodes to a list; in essense it is creating a tree. When I add a node to the tree, I use malloc to create memory for the node and push it onto a stack. I then pop it from the stack and do a check. If the check passes I push it back onto the stack, if it fails, I want to delete the node so I use free() to free the memory that was created for it. What is happening when you look at the Task Manger in Windows (XP), it shows the memory being allocated and freed for the application, but when you look at the field called "Commit Charge" within Task Manager, it shows a constant rise in the amount of virtual memeory being used. This continues to grow until the program ends with a memory allocation error. My question relates to resources/links/recommendations on how to better handle memory within a C++ program. I am using Microsoft VC++, version 6.0. I've looked through the code for memory leaks, but it it appears to do as it should; allocating and releasing memory in the proper order. Since it appears that memory leaks is the cause, I am looking for links or recommendations on how to find these leaks.
Any recommendations or resources would be greatly appreciated.
Thanks in advance.
Martin
|
|
|
|
|
My first question would be why are you not using the new and delete operators?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Well the first thing you should do is get a memory validator program that checks for resource leaks. There are several out there, I use Bounds Checker but I sure one of the others would work just as well. It has been a while since I visited any of thier sites, but they usualy offer a 30 day free trial that you can download, so it is well worth trying.
If the nodes of the tree are actualy class that allocate memory, you could be leaking it there. Since malloc and free no nothing about destructors and therefor will not call them, use new and delete instead.
You could also try using the memory validation functions in the SDK, they require adding additional code to your program inorder to use them, but I understand they work quite well. I beleive there is at least one article at CP some where, on this subject.
Good Luck!
INTP
|
|
|
|
|
i want to .....
Firstly,first sound(sound1.wav) is play until finished this sound,next secound sound(sound2.wav) is play.
my problems is sound1.wav and sound2.wav are both play.
i don't want two sound double play..
how to play one by one sound play.
how to know ???first sound finished time for secound sound start to play.
|
|
|
|
|
How about:
sndPlaySound(sound1.wav, SND_SYNC);
sndPlaySound(sound2.wav, SND_SYNC);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have a USB disk and know its Vendor ID(VID) and Product ID(PID). Perhaps this USB disk has several partitions. Here is my question which puzzled me so long: How to get the volume letters through the known VID&PID?
Thanks a million.
|
|
|
|
|
|
|
hello i just migrated from msvc6.0 to .net now im trying to work on an mfc project i had however i am not able to find anything like the mfc class wizard, i figured out how to add new vars but as far as events and viewing and modifying old variables via the class wizard i dont know what to do is there a central wizard type or have they completely removed that feature?
|
|
|
|
|