|
It's very simple
Override InitialUpdateFrame in your DocTemplate like that
void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
{
__super :: InitialUpdateFrame(pFrame, pDoc, false);
} Moreover, you can even write so:
void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
{
pFrame->DestroyWindow();
}
just set m_bAutoDelete to false in CYourDocument class before (constructor is the best place for it).
|
|
|
|
|
Sounds great, but I am just using CMultiDocTemplates in my code. I tried to make a subclass and override InitialUpdateFrame, but I get errors with the constructor, because CMultiDocTemplate has no default constructor. It doesn't seem like MFC wants DocTemplates to be subclassed, since we can't create them in the New Class wizard. So, how did you get that CProjectDocTemplate class?
thanks,
Jake
|
|
|
|
|
Jake Palmer wrote:
Sounds great, but I am just using CMultiDocTemplates in my code.
It does not matter. Look:
class CProjectDocTemplate : public CMultiDocTemplate
{
public:
CProjectDocTemplate ( UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass );
...
}
CProjectDocTemplate ::CProjectDocTemplate ( UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass ):
CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
{
}
....
AddDocTemplate( new CProjectDocTemplate(
IDR_DOC_PROJECT,
RUNTIME_CLASS(CProjectDoc),
RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CProjectView)
));
Where is the problem?
|
|
|
|
|
I found a solution: returning FALSE in my document's OnOpenDocument. I get to deal with the file the user opened, but then I don't have to mess around with a doc or view hanging around. How come nobody told me about that?
Jake
|
|
|
|
|
I am using a CTreeCtrl in my dialog based application, and I'm experiencing a really annoying problem with it. I should note that the "Check Boxes" style is being used with this tree control, and seems to be part of the problem.
When my dialog opens for the first time, I do not populate the tree control right away (the user does this later). However, a horizontal scroll bar shows up at the bottom of the tree control. From the looks of it, it would appear that an item with a *very* long name exists in the tree control. But I do a DeleteAllItems() during initialization, and the scroll bar still shows up!
I've noticed that if I manually insert some children, *AFTER* I do a DeleteAllItems(), the scroll bar does not show up (unless needed). But if I insert these children without first doing a DeleteAllItems(), the scroll bar shows up (needed or not). Could this be an indication that the TVI_ROOT item is starting with some garbage in it and needs to be properly initialized? If that's the case, how do I go about doing that?
I want the scroll bar to be available if needed, just not when the list is empty. Any ideas on how to fix this incredibly annoying problem are most welcome.
Thanks,
Jonah
|
|
|
|
|
I've never seen this problem. It could be the default checkbox image list is very wide or something; doesn't seem likely, but still, you could try setting a different state image list right off & see if that fixes the problem.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
>>1. How am I going to change the color of view in SDI from white to
something like black?
Use SetClassLong to change background color (GCL_HBRBACKGROUND)
>>2. How am i going to add another view in SDI?..do i have to change everything to MDI?
Not at all. Just add new class, derived from CDocTemplate and create it's instance in CYourApp::InitInstance like that
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTestDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CTestView));
AddDocTemplate(pDocTemplate);
|
|
|
|
|
Roman Fadeyev wrote:
Not at all. Just add new class, derived from CDocTemplate and create it's instance in CYourApp::InitInstance like that
Is this means doing something like this? (I've add a COutputView class derived from CView)
BOOL CPSMZayaxApp::InitInstance()<br />
{<br />
...<br />
CSingleDocTemplate* pDocTemplate;<br />
pDocTemplate = new CSingleDocTemplate(<br />
IDR_MAINFRAME,<br />
RUNTIME_CLASS(CPSMZayaxDoc),<br />
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CPSMZayaxView));
<br />
CSingleDocTemplate* pDocTemplate2;<br />
pDocTemplate2 = new CSingleDocTemplate(<br />
IDR_MAINFRAME,<br />
RUNTIME_CLASS(CPSMZayaxDoc),<br />
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(COutputView));
AddDocTemplate(pDocTemplate2);<br />
...<br />
}
When I execute the program, VC++ ask me to choose between the two view. How am I going to know which view is being displayed? How can I change from one view to another when the program was running? maybe this sound stupid but there was no minimize button to minimize one view and see the other like in the MDI I wish to init this view when I click a button on a DialogBox. What should I do?
Newbies
|
|
|
|
|
1. Override the views WM_ERASEBKGND message and paint with a black brush and then return TRUE.
2. I think you can do this without going to MDI. SDI means 1 document, not 1 view. Create a new view type like your first and add a document template for it. You should then be able to create instances of that view for your document as well. Although I don;t have all the code here for an example.
3. Not sure a width of 0 is valid. As far as I know 1 is the minimum pen width. You can probably get around the scaling issue by using the window mapping functions. Take a look at the MSDN for SetViewPortExt() and go from there.
4. Once again, you can set the display mapping mode to reflect this. See 3.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
1. Override the views WM_ERASEBKGND message and paint with a black brush and then return TRUE
If you will use WM_ERASEBKGND, it can result to a blinking whilst Window resizing. It is better way to change background brush in WindowClass properties.
|
|
|
|
|
Roman Fadeyev wrote:
If you will use WM_ERASEBKGND, it can result to a blinking whilst Window resizing.
No, if you handle WM_ERASEBKGND yourselft, the window class brush is not used.
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Tomasz Sowinski wrote:
No, if you handle WM_ERASEBKGND yourselft, the window class brush is not used.
I beg pardon, I was mistaken
I tested example below, all OK. Hmmmm, strangely...
BOOL CTestView::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
pDC->GetClipBox(&rect);
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
BLACKNESS);
return true;
}
|
|
|
|
|
As long as you don't go into ::DefWindowProc, the class brush remains unused. And it doesn't matter what you're returning from OnEraseBkgnd.
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Thank you very much guys. The black screen work just fine
Newbies
|
|
|
|
|
Roger Allen wrote:
Take a look at the MSDN for SetViewPortExt() and go from there.
From what what I've read, if I want to be able to scale, I have to use SetWindowExtent and SetViewportExtent functions. But when using the SetWindowExtent and SetViewportExtent, only two mapping modes are allowed : MM_ISOTROPIC and MM_ANISOTROPIC. The best part was both mapping mode have y going downward. I've tried using negative values in my y axis coordinate input so that my line will be drawn upward but I can't find my line anywhere.
Anyone has any idea?
Newbies
|
|
|
|
|
Whats the best method to select an Item in the list control. I can't seem to get it to work.
I've used SetSelectionMark and SetItemState both don't work. Theres some flickering but the items background colour does not change.
Am i missing something? is there another message I have to send?
Cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
list.SetItemState(itemIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Excellent...
That worked a treat.
Thanks
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
In addition to what Tomasz said:
You may also need to set the focus to the control to get he blue selection bar, or make sure that the "Show selection always" option is on in the resource editor.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
How can I set environment variables automatically (e.g. using bat file) without going in Control Panel -> System Properties -> Environment and adding them manually?
Thanks,
Michael
|
|
|
|
|
did you try ::SetEnvironmentVariable ?
-=c
"To announce that there must be no criticism of the president, or that we are to stand by the president right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public."
-- Theodore Roosevelt
|
|
|
|
|
I think, Michael wants to create constant environment variable, whereas ::SetEnvironmentVariable works only for the current process.
|
|
|
|
|
if you say so...
"To announce that there must be no criticism of the president, or that we are to stand by the president right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public."
-- Theodore Roosevelt
|
|
|
|
|
MSDN says
HOWTO: Propagating Environment Variables to the System
ID: Q104011
The information in this article applies to:
SUMMARY
You can modify user environment variables by editing the following Registry key:
HKEY_CURRENT_USER \
Environment
You can modify system environment variables by editing the following Registry key:
HKEY_LOCAL_MACHINE \
SYSTEM \
CurrentControlSet \
Control \
Session Manager \
Environment
Note that any environment variable that needs to be expanded (for example, when you use %SYSTEM%) must be stored in the registry as a REG_EXPAND_SZ registry value. Any values of type REG_SZ will not be expanded when read from the registry.
Note that RegEdit.exe does not have a way to add REG_EXPAND_SZ. Use RegEdt32.exe when editing these values manually.
However, note that modifications to the environment variables do not result in immediate change. For example, if you start another Command Prompt after making the changes, the environment variables will reflect the previous (not the current) values. The changes do not take effect until you log off and then log back on.
To effect these changes without having to log off, broadcast a WM_SETTINGCHANGE message to all windows in the system, so that any interested applications (such as Program Manager, Task Manager, Control Panel, and so forth) can perform an update.
MORE INFORMATION
For example, on Windows NT, the following code fragment should propagate the changes to the environment variables used in the Command Prompt:
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
(LPARAM) "Environment", SMTO_ABORTIFHUNG,
5000, &dwReturnValue);
None of the applications that ship with Windows 95, including Program Manager and the shell, respond to this message. Thus, while this article can technically be implemented on Windows 95, there is no effect except to notify third-party applications. The only method of changing global environment variables on Windows 95 is to modify the autoexec.bat file and reboot.
Additional query words:
Keywords : kbNTOS350 kbNTOS351 kbNTOS400 kbSysSettings kbGrpUser
Issue type : kbhowto
Love MSDN and your life will get better
|
|
|
|
|
Roman Fadeyev wrote:
Love MSDN and your life will get better
It'll be at its best when you just provide KB article ID or link, without copying whole article into the message board.
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|