|
Do not try to replace the text from within the dialog. Replace the text after the dialog closes, it is easier.
MyProjectDlg dlg; // dialog type now exist
// but the window does not exist yet
// therefor, you can not send it any messages.
According to your comments: The MyProjectDlg should already exist and it should be lunching the MyModalDialog, but here you are asking MyModalDialog to create a new MyProjectDlg and replace the selected text in that (which also does not exist).
void MyProjectDlg::SomeFunction()
{
MyModalDialog dlg;
dlg.MySetText(...);
if( dlg.DoModal() == IDOK )
m_fileContents.ReplaceSel(dlg.MyGetText(), FALSE);
}
INTP
|
|
|
|
|
Thanks a lot John, that worked out nicely.
dlarkin77
|
|
|
|
|
hi all,
I want to search File whether it is in the Hard disk or not.
How do I do this?
If any one know please send me a reply.
Thanks in advance..
|
|
|
|
|
programatically or by using the windows explorer search/find ?
programatically, use CFileFind ( or FindNextFile and FindFirstFile )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Get a copy of "Agent Ransack", it can find anything. There know there was an article here some where, but I can not find it.
You could write your own using the MS-C functions _findfirst() and _findnext() or the SDKs FindFirstFile() and FindNextFile(). The hard part is switching directories, for further searching. All the "File I/O Functions" functions are listed in the MSDN, you'll have to do a search for that exact string (not listed in index - as usual).
P.S. There is an article on "Agent Ransack" at CP.
Good Luck!
INTP
|
|
|
|
|
hi,
Thanks for ur reply..I found the "Agent Ransack" Article.But the problem is no free source codes in their Article.It is having exe only..
|
|
|
|
|
hi
I am doing a project using MFC/C++ .I want to run a exe file when clicking a Button in the Dialog.
please reply me the way to do it.
Thanks in advance..
|
|
|
|
|
|
There are Three Api' that can Help
Little Easy
--. WinExec()
--- ShellExecute() & ShellExecuteEx()
Little Tough for NewBies
--- CreateProcess
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I have made simple program for HTTP download in the Visual Studio .NET (VC++
7.0). I have overriden MFC class CAsyncMonikerFile. I have overriden method
OnStopBinding(HRESULT hresult, LPCTSTR szError) in my derived class , but
this method wasn't called at the end of the bind operation (when all data
came). But overriden method OnStartBinding()was properly called. Can you help
me with this problem? Is there any serious bug in the MFC class
CAsyncMonikerFile in VC++ 7.0?
|
|
|
|
|
I do not know why you overrode the OnStopBinding() function/method, but is sounds like you need to call the base version in your overriden version.
OnStopBinding(...)
{
BaseClass::OnStopBinding(...);
}
INTP
|
|
|
|
|
Hi John,
I have to call some functions, when all data are downloaded and the OnStopBinding is right place for it. But the problem is that OnStopBinding is not called in VC++ 7.0, but in older VC++ 6.0, everything was all right (OnStopBinding is called after OnDataAvailable()).
|
|
|
|
|
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 : )
|
|
|
|