|
this seems to work on 2k.. not sure if its exactly what you want but I jus threw this into a dialog and it worked as expected.
CRect pRect;
GetDesktopWindow()->GetWindowRect(pRect);
MoveWindow(pRect);
Rob
|
|
|
|
|
or if you dont want it maximized just have the ability to be moved over the top of the start bar..
SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE );
Rob
|
|
|
|
|
This is a bit, but it shows how to create a full-screen view like VC++ and MS-WORD. If you need an explanation on how it works I can post the rest. But this is what you need to make it work.
Step 1. Add two Boolean member variables to your main application window class
<code>class CMainFrame : public CMDIFrameWnd
{
protected:
BOOL m_bFullScreen;
BOOL m_bWasZoomed;
};</code>
Step 2. Add code to the constructor of your main application window class to initialize to FALSE the member variables added in step 1:
<code>CMainFrame::CMainFrame()
{
m_bFullScreen = FALSE;
m_bWasZoomed = FALSE;
}</code>
Step 3. Add the "View, Full Screen" menu command to all your menu resources. Because this command is handled by the main application window, it should always be available whatever the currently active document or view type. Optionally add a toolbar button for the "View, Full Screen" command.
Step 4. Use ClassWizard to add an 0N_COMMAND handler in your main application window class for the "View, Full Screen" menu command. Use ClassWizard again to add a handler for the WM_GETMINMAXINFO message to your main application window class. Implement these handlers as shown below. Note that these two functions work in coordination to achieve the desired behavior.
<code>void CmainFrame::OnViewFullScreen()
{
int cyCaption = ::GetSystemMetrics( SM_CYCAPTION );
int cxFrame = ::GetSystemMetrics( SM_CXFRAME );
int cyFrame = ::GetSystemMetrics( SM_CYFRAME );
int cxScreen = ::GetSystemMetrics( SM_CXSCREEN );
int cyScreen = ::GetSystemMetrics( SM_CYSCREEN );
int cyMenu = ::GetSystemMetrics( SM_CYMENU );
m_bFullScreen = ! m_bFullScreen;
if( m_bFullScreen )
{
m_bWasZoomed = IsZoomed();
if( m_bWasZoomed )
{
SetWindowPos( NULL,
-cxFrame,
-( cyFrame + cyCaption + cyMenu ),
cxScreen + 2 * cxFrame,
cyScreen + 2 * cyFrame + cyCaption + cyMenu,
SWP_NOZORDER );
}
else
{
ShowWindow( SW_SHOWMAXIMIZED );
}
}
else
{
if( m_bWasZoomed )
{
SetWindowPos( NULL,
-cxFrame, -cyFrame,
cxScreen+2*cxFrame,
cyScreen+2*cyFrame,
SWP_NOZORDER );
}
else
{
ShowWindow( SW_RESTORE );
}
}
}
void CmainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
int cyCaption = ::GetSystemMetrics( SM_CYCAPTION );
int cxFrame = ::GetSystemMetrics( SM_CXFRAME );
int cyFrame = ::GetSystemMetrics( SM_CYFRAME );
int cxScreen = ::GetSystemMetrics( SM_CXSCREEN );
int cyScreen = ::GetSystemMetrics( SM_CYSCREEN );
int cyMenu = ::GetSystemMetrics( SM_CYMENU );
CFrameWnd::OngetMinMaxInfo( lpMMI );
if( m_bFullScreen )
{
lpMMI->ptMaxPosition.y = -( cyFrame+cyCaption+cyMenu );
lpMMI->ptMaxSize.y = lpMMI->ptMaxTrackSize.y =
cyScreen+2*cyFrame+ cyCaption+cyMenu;
}
else
{
lpMMI->ptMaxPosition.y = -cyFrame;
lpMMI->ptMaxSize.y = lpMMI->ptMaxTrackSize.y = cyScreen+2*cyFrame;
}
lpMMI->ptMaxPosition.x = -cxFrame;
lpMMI->ptMaxSize.x = lpMMI->ptMaxTrackSize.x = cxScreen+2*cxFrame;
}</code>
At this point, your application already supports the full-screen view. However, you may wish to add a nice touch to the implementation by helping the user get back from the full-screen view to normal mode by simply pressing the Escape key. To do this, follow these additional steps:
Step 5. Create a new resource symbol called (for example) ID_VIEW_BACK_TO_NORMAL. (Click "View, Resource Symbols" click the New button.)
Step 6. Use ClassWizard to add an ON_COMMAND handler in your main application window class for the ID_VIEW_BACK_TO_NORMAL symbol that you defined in step 5. Implement this handler.
<code>void CmainFrame::OnViewBackToNormal()
{
if( m_bFullScreen )
{
OnViewFullScreen();
}
}</code>
Step 7. Edit your IDR_MAINFRAME accelerator table to define a new accelerator entry that associates the Escape key with the ID_VIEW_BACK_TO_NORMAL symbol that you created in step 5.
|
|
|
|
|
I am looking for a way to do a 3 state item similar to the 3 state check box. My boss doesn't like the way that the 3 state checkbox looks and wants me to find an alternative. I havn't seen anything here so far but I probably missed something. I'd appreciate any help.
Thanks,
Amy
|
|
|
|
|
Funny how easily some people say they don't like something but yet don't offer an alternative. I would tell your boss that unless he knows of an alternative, that a 3-state checkbox is the way to go. It's a standard Windows behavior:
Checked on White = all of the options are selected
Checked on Gray = some options are selected, some aren't
Not Checked = none of the options are selected
I've seen this type of checkbox in installation programs more than anything else. How are you planning on using yours?
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
It will be used as a binary toggle, either it is 1, 0, or neither. He likes how it works he just thinks that when it is in the neither(gray) state it looks too much like the ones that are disabled. There are a few places where it will be mixed in with disabled options. Visually it is difficult to tell the difference until you click on it.
Amy
|
|
|
|
|
The only alternative I can think of is radio buttons. They occupy more space but they should definitely clear things up on your dialog box:
Do you like this? O Yes O No O Dunno
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thanks,
Do you know if it is possible to change the color of the regular tri-state checkbox?
Amy
|
|
|
|
|
hi,
I need to get the difference (in minute) between two variables of type DATE.
Example:
<br />
DATE d1;
DATE d2;
Thanks in advance
Newbie
|
|
|
|
|
see the COleDateTime and COleDateTimeSpan classes.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
The easiest way is to convert the DATEs to COleDateTime objects and use the COleDateTimeSpan class to determine the difference:
COleDateTime dtm1 = d1;
COleDateTime dtm2 = d2;
int minutes = static_cast<int>((dtm1 - dtm2).GetTotalMinutes());
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Howdy'
I'm trying to implement a simple drag'n'drop of objects and I want to be able to drop them outside my application to create new windows ( i.e. detach some element from the main window )
I'm now use the drag'n'drop mechanism to drag some info between the source and the target, which is ok, but I don't/can't drop to somewhere else ?
[Question part ... ]
I've added a derived COleDropTarget to my mainframe and registered the target window, all is working ok inside the application, but I don't exactly know what to register if I let go of the button anywhere else on the screen, whether it's the desktop window, or any other windows under the mouse at that point; I don't think that I have to register a type because I'm not using the clipboard.
The other alternative that I'm trying , is to "simulate" the drag'n'drop by capturing the mouse ( SetCapture ) and processing stuff in the MouseMove and on the MouseUp, do the "drop"; I'm loosing some of the functionnalities that the drag'n'drop automatically offer.
Thanks, and sorry for the rambling ...
Max.
|
|
|
|
|
It seems to me that your simulation technique would be a good method, and I see your point about losing certain Drag and Drop functionality that OLE provides for you.
What if you were to create a transparent window, that fit over the entire desktop when these particular items were to be dragged off of your main window. Then your transparent window with no borders, no caption, and no paint routines could become a drop target. When the user cancelled the drag and drop, or after they dropped the item on your transparent window, the window would go away.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hello,
This is probably a really dumb question.. I created a SDI with a splitter.. when I close the app it asks me if I want to save before exit.. How do I get rid of that prompt? Over ride one of the OnClose functions?
Thanks,
Rob
|
|
|
|
|
that's one way. another way would be to set the doc's modified flag to FALSE. (SetModifiedFlag(FALSE)). that should do it.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
The problem has to do with the modified flag inside your document being set somehow. Read up on SetModifiedFlag, IsModified, and SaveModified.
It seems to me like the quickest solution is just to override SaveModified in your CDocument-derived class and make it return TRUE:
BOOL CYourDocument::SaveModified()
{
return TRUE;
}
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Works perfect, Thanks to both of you!
|
|
|
|
|
hi all,
I'm trying to do an strcmp() with a REG_SZ value.
I'm loading the REG_SZ into an unsigned char[] like this:-
unsigned char lpstrValueData[MAX_PATH];
dwRegStatus=RegQueryValueEx(hKey, "DisplayName", NULL, &dwType, static_cast<LPBYTE>(lpstrValueData), &dwcbData);
then, i want to compare it with a string...
strcmp(lpstrValueData, "MyString");
Perhaps obviously, this doesn't work becuase:-
error C2664: 'strcmp' : cannot convert parameter 1 from 'unsigned char [260]' to 'const char *'
so, i try this instead:-
strcmp( static_cast<const char *>(lpstrValueData), "MyString");
but this doesn't work either:-
error C2440: 'static_cast' : cannot convert from 'unsigned char [260]' to 'const char *'
which is wierding me out. A nasty C style cast like this works:-
strcmp( (const char *) lpstrValueData, "MyString");
so why doesn't static_cast like it?
The expression static_cast < type-id > ( expression ) converts expression to the type of type-id based solely on the types present in the expression. No run-time type check is made to ensure the safety of the conversion.
help!
#include <beer.h>
|
|
|
|
|
If you don't like the C cast syntax, you can resort to reinterpret_cast (which is basically the same). I sort of agree with you that static_cast whould be allowed here, but alas C++ rules are the way they are.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks Joaquín!
#include <beer.h>
|
|
|
|
|
Not too shocking since they are two totally different types.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
static_cast is a compiler time casting operator that insures type safety. So nothing is done at runtime when you use the static_cast.
reinterpret_cast is more like the C-style cast. It basically says that you are going to take responsibility for the casting that is done, and there is no type-safety checking performed with this cast.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Doesn't that depend on the type of casting performed?
E.g. Take the following C lines:
myInt = (int)myFloat;<br />
myCharPtr = (char *)myVoidPtr;
I would use static_cast for the first one, and reinterpret_cast for the second one.
If I would use
myInt = reinterpret_cast<int>myFloat; wouldn't that cause the compiler to intepret the bit-pattern of myFloat as the bit-pattern of an int, causing garbage to be assigned to myInt?
That leaves me with the other two casts:
const_cast: for casting way the const (wouldn't volatile_cast be a better name?)
dynamic_cast: for casting instance-pointers from one type to another, checking dynamically whether it is the correct type or not.
<marquee>Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
I have this weird problem where a call to CReBar::AddBar() crashes my
program.
This only happens in VC++ .Net in Release mode. If I run the code from the
debugger (F5) it doesn't happen. If I compile a debug version of the code it
doesn't happen either.
So basically I get a crash every time I compile a release build and I
execute the program from outside the debugger.
As you can imagine, I'm having a very hard time debugging this!
Has anyone seen this problem before? Any idea what might be causing this?
Any suggestion/idea is welcome. Thank you.
|
|
|
|
|
Anyone knows where can i remove those custom ie toolbars installed by other programs?? Is it somewhere in the registry?
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|