|
The default OnFileSaveAs implementation calls CDocument::DoSave with NULL parameter. NULL means 'suggest simple name (based on document template) and display SaveAs dialog box". You can't call DoSave with your suggested name - this will disable the dialog box. DoSave is a virtual method, you can override it, but you can't just call base class. You'll have to copy the CDocument::DoSave body into CYourDoc::DoSave --and-- replace the code that calls CDocTemplate::GetDocString with your own routine creating suggested name.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi!
I'm having problem with the line
cs.lpszClass = AfxRegisterWndClass (CS_NOCLOSE);
in PreCreateWindow function of the MainFrame
I want to disable the "x" (close) button in the upper right corner. That works with the:
cs.lpszClass = AfxRegisterWndClass (CS_NOCLOSE);
But there's a catch, if I use that line my program my applicatin icon (in the upper left corner and when minimized) is replaced by some ugly windows icon!
Is there another way I could do this?
Lynse
|
|
|
|
|
|
Ok, I'm a beginner at this so how do I get a handle to an icon in the resource file ?
Lynse
|
|
|
|
|
|
Hi,
I was wondering if there is any somewhat convenient way of "overriding" the new limitation of SetForegroundWindow() [for Windows 2000] (i.e. that it in fact does not set the window in foreground at all, but merely flashes it.)
I'm developing a small app where it would be nice if it could in fact sit in the background for a while, and then pop up on top of everything else when it's finished. How do I do this now that MS have closed the official door?
It can still be done, as for instance MS own Internet Explorer tends to do this all the time...
Thanks!
--
/Daniel
|
|
|
|
|
This is a short in the dark, have you tried SetActiveWindow after your App finishes working?
HTH
Jignesh
|
|
|
|
|
You have to implement it like this, in the app(windowhandle) you want to pop to the top:
Sleep(1);
BOOL btemp = SetForegroundWindow( (HWND) windowhandle );
if (!btemp)
{
Sleep(1);
btemp = SetForegroundWindow( (HWND) windowhandle );
}
You need the sleep since the system imposes a min switch time (and the originating app must be finished or at least released it's timeslice). Check the min switch time with:
BOOL bResult = SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,timeout,0);
Regards
Boris
|
|
|
|
|
Hi all,
I'm trying to open a video stream but problems arise. Have a look at the code below:
::CoInitialize(NULL);
::AVIFileInit();
PAVISTREAM pAvi;
HRESULT hr = ::AVIStreamOpenFromFile
(&pAvi, "any.avi", streamtypeVIDEO, 0, OF_READ, NULL);
if (SUCCEEDED(hr))
{
AVISTREAMINFO si;
::AVIStreamInfo(pAvi, &si, sizeof(AVISTREAMINFO)); // <- Works ok
IGetFrame *pGetFrame;
pGetFrame = ::AVIStreamGetFrameOpen(pAvi, NULL); // <- Always returns NULL
if (pGetFrame != NULL)
{
pGetFrame->Release();
}
pAvi->Release();
}
::AVIFileExit();
Now, according to msdn, AVIStreamGetFrameOpen() returns NULL if it could not find a decompressor for this specific file. I can however view the file in windows media player w/o any problems. Doesn't that imply I do have a decompressor installed for this file???
I'm confused. Any help on this would be appreciated.
/Niklas
|
|
|
|
|
Hy!
How can I write in the window of a SDI aplication ( derived from CEditView ) from a worker thread??
Bye,
Orbital
...the night is long ... but not long enought to do some real coding ...
|
|
|
|
|
|
No, it dosen't because this function return the window caption. Here is what MSDN say :
"Copies the CWnd caption title (if it has one) into the buffer pointed to by lpszStringBuf or into the destination string rString. If the CWnd object is a control, the GetWindowText member function copies the text within the control instead of copying the caption. "
Bye,
Orbital
...the night is long ... but not long enought to do some real coding ...
|
|
|
|
|
|
I know you can ... but in the answer I specified that I want to change it from a worker thred and the function provide by CEditView are not thread-safe ... if you have any idea whow to workaround this problem I will gratly apreciate ...
Bye,
Orbital
...the night is long ... but not long enought to do some real coding ...
|
|
|
|
|
|
I've tryed that one to ... but i relly don't want to mdify the MFC source code ... any idea where i can put that critical section ( one is in the worker thread but the ather?? )
Bye,
Orbital
...the night is long ... but not long enought to do some real coding ...
|
|
|
|
|
Why do you want to modify MFC sources? Just use a critical section to ensure that your threads don't use SetWindowText at the same time.
- add the CCriticalSection member, m_csection, as a private member to CYourEditView
- add new method and use it instead of 'plain' SetWindowText:
void CYourEditView::SafeSetWindowText(LPCTSTR szText)
{
CSingleLock lock(&m_csection, TRUE);
SetWindowText(szText);
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
hi all,
i want to know how can i progam parallel port in NT. as i tried b4, outportb() is not possible to use in NT. any method to program parallel port in NT?
thanks,
jim
|
|
|
|
|
See CreateFile(). this is a genric function used for opening both files and devices. You can then use WriteFile and ReadFile to talk to it.
|
|
|
|
|
Please help me,
I've been trying to solve this problem for more than a week now:
I have to open a textfile with a common dialog box, put this file in a buffer, then I have to show this text in a richeditcontrol by calling the buffer.
Oh, yeah: these text files are at least 1MEG big and I'm just getting started with MFC, glups !
Thanks if you can help me...
|
|
|
|
|
|
Cannot open include file...
Microsoft's products are perfect as always.
What should I do?
Lio.
|
|
|
|
|
mfc42ud.lib is not a header file - it's a library. Anyway, you should set the active configuration to non-unicode before building the sample.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
You could use SetText()
or stream the text in with a callback function something like:
DWORD CALLBACK readText(DWORD dwFileHandle, LPBYTE lpBuffer, LONG nbrToRead,
LONG FAR* lpNbrRead)
{
BOOL file = ReadFile((HANDLE)dwFileHandle,lpBuffer, nbrToRead,
(unsigned long*)lpNbrRead, NULL);
if(file == FALSE ){
AfxMessageBox(_T("Could'n open file!"),MB_ICONEXCLAMATION);
return 1;
}
return 0;
}
and then call it with something like this:
EDITSTREAM stream;
HANDLE hFil;
fFormat = SF_TEXT;
strom.dwCookie = (DWORD)hFil;
strom.pfnCallback = readText;
m_recText.StreamIn( fFormat, strom );
/Per
|
|
|
|
|
OK, I've had a better look at it now.
I still have one question: how do I declare m_readText?
Thanks in advance. Lio.
|
|
|
|