|
I have a Dialog project that when compiled will only show the MFC Icon with Windows Explorer. If you click on the file and display properties, then the Icon displayed is the one that I created for it.
Any suggestions as to what I am doing wrong.
Thanks in advance.
Eldon Zacek
Czech-Mate Enterprises, LLC
|
|
|
|
|
Change both the 32x32 sized icon AND the 16x16 and your problem may be fixed.
-KMAZ
|
|
|
|
|
In the VC++ icon editor, there are several available icon types. The one that is normally displayed with your app is the 32x32 size but a second one is also created by default of size 16x16. Explorer usually uses the smaller one. To fix your problem, redraw the smaller one too and rebuild your app.
I am always doing this myself too.
|
|
|
|
|
You have to make sure that there is a 16x16 icon in the icon itsef. Open the icon in Visual Studio and make sure there is a 16x16 version of the icon.
Regards,
Brian Dela
|
|
|
|
|
I want to do the same that MFC do when the New Document option in Menu is pressed.
What I have to call?
I've tried Doc->OnNewDocument() but is not the same, because the view is not refreshed. I think the call has to be related to OnFileNew of app but I don't know what's the correct sintaxis.
Best Regards
Dr.Pi
|
|
|
|
|
How about the following:
AfxGetMainWnd()->PostMessage(WM_COMMAND,ID_FILE_NEW);
|
|
|
|
|
|
I have a problem at the middle of my work. I don't want to restart from the beginning.
Right now, I am writting a software in C++ with MFC. I use the Message MAP builded by the Wizard. I don't want to tell what kind of software I do because it is confidential. This is a tool used on PC, which communicate with an embedded system.
I don't need a real time software, the time is not critical. We also want something friendly. That is why my interface is Window. At this time, everything work, for the futur, I see a problem.
The problem is the following:
-----------------------------
When a process is currently running (not finish), I want to exit from my function, do something else, and come back to see if I have the result of that process or exit if the timeout is elapsed. To do so, I need to Dispatch the Message
by myself like the old method with the Windows Procedure and the switch case with different messages. I know very well how to do it but now, I have a software with a message map. Bad or good decision, I am not sure at this time.
My solution is to restart a new project with old fashion and control all message with the switch case (no message map). I can also recuperate all my files.
Other problem, the old method use HANDLE, MFC doesn't.
Is there something I don't understand ????
Please, help !
Danny
|
|
|
|
|
MFC map is the switch statment just add your message to it
|
|
|
|
|
I am not sure what the problem is but there should be an easy solution with mfc. Can you execute your function in a seperate thread?
If you want the old switch / case all you have to do is override WindowProc(). I did this in a directdraw application.
Danny Gilbert wrote:
Other problem, the old method use HANDLE, MFC doesn't.
What do you mean here. In most cases in MFC you have access to the handle.
John
|
|
|
|
|
You can make your own message pump wherever you want with this code:
if(::PeekMessage(&msg,m_hWnd,0,0,PM_REMOVE))<br />
{<br />
::TranslateMessage(&msg);<br />
::DispatchMessage(&msg);<br />
}
to check for an event or message inside your function and the come back to your process.
Daniel Cespedes
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
If I understand, you says that I can stay in my process and call (for exemple at each loop) the PeekMessage, Translate and Dispatch Message functions !!!
So, Windows will execute the function (like refreshing the screen, etc.) and always come back at the caller, in my process.
Is it what you explain ?
|
|
|
|
|
exactly!!
Daniel Cespedes
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
God, you reminded me of doing background processing in Win16. Shame on you!! It took me a long time to forget!!
onwards and upwards...
|
|
|
|
|
well it works fine in my codes, and I have taken the code from Programming Visual C++ fifth Edition from Kruglinsky, a rather new book.
Is a method that sometimes makes multithreaded programming unnecessary.
greetings.
Daniel Cespedes
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Multithreading does have its problems besides the difficulty with synchronizing shared objects, its harder to debug, and MFC doc / view does not support multithreading. However after you get over a few hurdles it is usually better to use unless you only have one background task.
John
|
|
|
|
|
I didn´t know that MFC doc/view doesn´t support multithreading, so if I want to use it I have to make a Dialog based app?
cheers!
Daniel Cespedes
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
John M. Drescher wrote:
MFC doc / view does not support multithreading
I didn´t know that MFC doc/view doesn´t support multithreading, so if I want to use it I have to make a Dialog based app?
cheers!
Daniel Cespedes
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
No you just have to make sure that you create your views in the same thread as the doc and the main application otherwise you will see a lot of asserts...
John
|
|
|
|
|
I was thinking the same...
John
|
|
|
|
|
How would I go about to solve this problem?
I have to write a text analysis program that will calculate and output the overall number of words, characters, and lines within a text file. Also, have to calculate how many characters are alphabetic, numeric, and punctuation.
It has to be in C++. Thanks.
Sample Output:
The text file consisted of 2 lines
The text file consisted of 27 words
The text file consisted of 128 characters
Alphabetic: 100
Numeric: 12
Punctuation: 8
Other: 8
Mark J Jackson
|
|
|
|
|
Use the following functions from <ctype.h>
isalpha
isdigit
ispunct
isspace
|
|
|
|
|
CString strLine;
CStdioFile file(...);
int nLineCount = 0,
nAlphaCount = 0;
while (file.ReadString(strLine) == TRUE)
{
nLineCount++;
for (x = 0; x < strLine.GetLength(); x++)
{
if (isalpha(strLine[x]))
{
nAlphaCount++;
}
else if (isdigit(strLine[x]))
{
nDigitCount++;
}
...
}
}
// to count characters (or count them above as each character is analyzed)
int nCharCount = file.GetLength();
|
|
|
|
|
Hi everyone,
I have a little question about thread. I have read the faq and managed to program threads but now I'm facing a newbie challenge : I need to access to my dialog controls and the Document. I copy this code from this forum to access the Document from anywhere in my program.
//Declaration
static CTestSDIDoc * GetDoc();
//Implementation
CTestSDIDoc * CTestSDIDoc::GetDoc()
{
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
return (CTestSDIDoc *) pFrame->GetActiveDocument();
}
In my dialog (my own progress window with static text, a progress bar, 6 bitmaps and an OK button), I want to show a green check mark when a process has done is job. The process is created with CreateProcess method. The CreateProcess is writed in the TreadFunc of my dialog class. Before calling createprocess method, I must do some initialization in the Document so I must do this :
metprof *metProfPtr = static_cast<metprof *="">(pvParam);
CTestSDIDoc *pDoc = static_cast<ctestsdidoc *="">(pvParam);
pDoc=CTestSDIDoc::GetDoc();
The bold text code works everywhere except in the TreadFunc method (I've got an assertion when running in debug mode). I want to know what Am I doing wrong ?
Here my complete ThreadFunc function:
UINT metprof::ThreadFunc(LPVOID pvParam)
{
metprof *metProfPtr = static_cast<metprof *="">(pvParam);
CTestSDIDoc *pDoc = static_cast<ctestsdidoc *="">(pvParam);
CString workingDirectory,strTemp,appArguments,strTemp2;
pDoc=CTestSDIDoc::GetDoc();
TRACE("vis: %d\n",pDoc->m_VIS);
workingDirectory=pDoc->m_modulesDirectory;
workingDirectory.Insert(workingDirectory.GetLength(),"ATMOSPHERIC\\\\");
pDoc->m_SL_COND=1;
appArguments=pDoc->m_dosPrompt;
pDoc->createMetDataFile();
pDoc->createMetProfInputFiles();
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
strTemp2=pDoc->m_binDirectory;
strTemp2.Replace("\\\\","\\");
strTemp2.Delete(strTemp2.GetLength()-1,1);
strTemp.Format(" /c \"metprof.exe < metprof.rep -L -P \"%s\"\"",strTemp2);
appArguments.Insert(appArguments.GetLength(),strTemp);
char *str = appArguments.GetBuffer(appArguments.GetLength());
if(CreateProcess(NULL, // Application name
str,//"cmd /c \"metprof.exe < metprof.rep -L\"",// Application arguments
0,
0,
FALSE,
CREATE_NO_WINDOW,
0,
workingDirectory,//"C:\\Program Files\\Irblempkg\\IRBLEM4.1\\modules\\atmospheric\\", // Working directory
&siStartupInfo,
&piProcessInfo)){}
::WaitForSingleObject(piProcessInfo.hProcess,INFINITE);
metProfPtr->GetDlgItem(IDC_CHECKMETEO)->ShowWindow(TRUE);
pDoc->moveMetProfOutputFiles();
return 0;
}
I think I'm missing something with my code but I don't know what.
Thanks for your help,
Rene
|
|
|
|
|
Yeah, you are missing the bold text . Which part of the code does not work?
|
|
|
|