|
Hi
I want to change the default cursor in my app. I tried following code.
bool m_bcursor;
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
lhCursor = AfxGetApp()->LoadCursor(IDC_CURSOR);
SetCursor(lhCursor);
m_bcursor = true; //set to true
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CTestDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
if(m_bcursor)
return true;
else
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
But whenever I open About Dialog, cursor it changed to default cursor.
What should I do to change cursor the moment my main dialog gets focus?
|
|
|
|
|
You need to set the cursor each time the OnSetCursor message is triggered. Dump the boolean member variable, and make the handle to the cursor a member variable of the dialog box:
HCURSOR m_hCursor;
Initialize it in the constructor:
CMyDialog::CMyDialog() : m_hCursor(NULL)
{
m_hCursor = AfxGetApp()->LoadCursor(IDC_MYCURSOR);
}
and in OnSetCursor()...
if (m_hCursor != NULL)
{
SetCursor(m_hCursor);
return TRUE;
}
// default stuff here
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Good advice! But you do not need to maintain a copy of the cursor handle.
From MSDN:
"The LoadCursor function loads the cursor resource only if it has not been loaded; otherwise, it retrieves the handle to the existing resource."
In other words, the system maintains a copy of the cursor handle for you.
SetCursor(AfxGetApp()->LoadCursor(IDC_MYCURSOR));
The cursor is a resource included in the .exe (or sytem resoruces). Therefore, you do not need to test the handle. If the handle returned is not valid then there is a much bigger problem involved (and the program has locked up or crashed, do to lack of memory).
INTP
|
|
|
|
|
can you write the W32 api code for changing a cursor. I never got to do it. . ..
I hate cursors
gabby
|
|
|
|
|
hi Jack Rabbit
thanks a lot.
it worked for me.
|
|
|
|
|
hello
I want to use mscomm32 activex in an mfc activex that I am writing now.
but because my activex is not a container, I can not create an instance of it!!
what should I do?
thanks
Kamyar Souri
|
|
|
|
|
I need to delete the row that was clicked !!!
How should i do?????
|
|
|
|
|
|
This is the code:
selected=SendMessage(GetDlgItem(hdlg,IDC_LIST1),LB_GETCURSEL,0,0);
SendMessage(GetDlgItem(hdlg,IDC_LIST1),LB_DELETETEXT,selected,0);
gabby
|
|
|
|
|
Hi,
I'm trying to build an application that needs to read the position of a mouse (not the system's mouse) from the serial port.
Can anyone help me, and explain me how the mouse reads data from a port?
Thanks.
|
|
|
|
|
dont think on this problem as a hardware problem!!
easiest way is to handle onMouseMove for a big static control!!!
and use the passed x,y
Kamyar Souri
|
|
|
|
|
Anonymous wrote:
(not the system's mouse)
What does this mean? There is normaly only one mouse attached to a computer. You can retreive its positon on the screen at any time by calling GetCursorPos() (on a Windows machine).
If you need lower level access, then you may need to write your own driver (not a good idea!).
INTP
|
|
|
|
|
Hey every one...
I am asking about how to creat exe files from my application...
I want to make a program that creat other .exe files with a specific values.
for example, When I am running my application, I enter a value (let's say my name) and click on a button named "creat", then an valid exe file will be created and the value (my name) will be inside it.
thanks : )
|
|
|
|
|
what you're asking is very simple but I am curious what would you like the exe to do.
and then I will give you a solution
gabby
|
|
|
|
|
I liked your answer.
To many of the quesions (small amount) seem to be aimed in the wrong direction.
This is a new one and I would also like to know what he would what it to do.
INTP
|
|
|
|
|
:-DHey
what's happening here.
????????
|
|
|
|
|
I don't know why you thing I will use it in the wrong way?
( I don't know how it can be used in a wrong way?)
and I want the exe file to include some buttons and edit box, or maybe include some codes to solve a math. question or any thing else.
why I want exe file?
because it is an extension file, and I already study how to make the other files, like .txt or .html, but never learnt how to make .exe files
so I will be thankful for any help, and Believe me I am not going to use it in wrong way.
|
|
|
|
|
I think you are looking for Dialog based application.
here is Some step that will help-:
!-Open MS Visual Studio 6.0
!-Click on FILE|NEW,and wait for property page to open.
!-select PROJECTS|MFC AppWizard(exe),Do remember to give the name of project.CLick Next
!-Select type to Dialog based,and click next till wizrad over.
!-now you are presented with Dialog Box editor,drag and drop your Control to Dialog box,build and execute the Preoject to see your exe
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Yeah I know, but I want my project which is an exe file to creat other exe files.
thanks alot
|
|
|
|
|
you must first have the contetnt of the exe file somewhere. in the resources or just in an ordinary file.
then you open the new file where you want it to be created:
FILE *exec;
exec=fopen();
while(true)
{
data=readfile(oldfile);
fprintf(exec,data);
}
this is the idea of the code.
To load it from the resources is a little longer code and I am tired so I won't write the code. try to read the MSDN more.
good luck.
|
|
|
|
|
thank you. I think he ust said what the exe should do but it seems kind of hard to do.
gabby
|
|
|
|
|
Thank you very much for your help.. I got also the idea of how to do it, but I still can't do it.... can you give which title i should search in MSDN
I know it is hard, but I will not give up
thanks again
|
|
|
|
|
Hmmm hard to tell.... The MSDN is really big.
What sort of problem are you having now. If it is about manipulating files read about I/O functions which you can find by going to the index tag in the MSDN and type any of the functions (ex CopyFile) and in the bottom of the page you get a link like this:
See Also
File I/O Overview, File I/O Functions, CopyFileEx, CreateFile, MoveFile ;
You may choose any of those but it advisable that you should choose "File I\O overview".
Then if you have problems with manipulating strings go to the index tag as well in the MSDN and write a str function ( ex: strcmp) then you will see that the function has also an example along with the explanation. In the bottom of the page you get this link: "String Manipulation Routines". Push it and you will see al the possible functions all with an exapmle each.
I thing that these were the issues you where concerned in, otherwise tell what exactly can't you do.
Good Luck.
gabby
|
|
|
|
|
Thanks alot man... your replay includes many things, so I need to be over them all, and try it one by one... so it will take some time until I ask the next question
I am very thankful for your help
thanks again
|
|
|
|
|
no problem I am here to help whenever is neccesary.
gabby
|
|
|
|