how to make modaless mfs - c++

hi im using mfc in c++,
and i need to make it modaless,
and also i need to have a function which turn on and off the gui,
which also i dont know how to do.
Thanks

Hi you need to read http://www.codeproject.com/KB/dialog/gettingmodeless.aspx and source http://msdn.microsoft.com/en-us/library/175y2765(v=VS.80).aspx
If you mean turn off gui as do not show dialogs then just dont show it use console or hidden windows

Related

Stealing focus (for a good reason)

I'm working on a clone of Yakuake and, if you have used it, you'd know that one of it's features is stealing the focus for easiness.
Basically, you hit the "show" hotkey, the app appears and you can write on it.
You could be doing whatever thing with whatever app, (being Yakuake hidden), but as soon as you hit the hotkey, Yakuake appears and steals the focus. I want to do the same with my app.
I know there are some window manager rules that prevent applications from doing this, but Yakuake is doing it, why I'm not able to do it?
Also, this application is meant to be compatible with Windows, Linux and Mac, so no KDE or Gnome or < insert_your_favourite_window_manager_here > hacks; I won't go the detect-WM-and-do-hack way.
PS: I'm doing that app in C++ and Qt4.
EDIT:
Just to make it clear, I'm not asking for any code (but if you actually have some example, I appreaciate it). I'm asking for a way for doing it. What should I do to make the WM assign the focus to my app. Is there any standard way for doing so?
There is the Qt::WindowStaysOnTopHint....
The solution is simpler than I thought. I did an animation with a duration of 0s and at the end of the animation I just did a focus. This did the work.
If you want to do it with a "show" hotkey or shortcut you'll have to create and use a hook on the keybord.
Qt don't provide such things so you'll have to do it by yourself.
you can have a look at this post : QT background process
I don't know for other OS.
When you'll get the right keyboard event from your hook, you can create a window with the "allwas on top hint" and that should by ok.

Is it possible to embed a command prompt in a win32 app?

In linux and when installing packages etc. There are some installers that have a progress bar and a dos window which shows the files being extracted etc. How can i add this window to my C++ Win32 programs so that i can have it showing the tasks im doing? I cannot find any documentation on MSDN.
Question: How can i add a console window (if that's what its called, sure looks like one) in my program to show the details of the task at hand being done?
Here is a window with what i am asking.. (personal info so I erased the details. :]
You cannot embed a real console window inside another window (although a windowed process can have a separate console window). While it looks like a console window / command prompt, it is just a matter of appearances. What you want to do is create a sub-window/control with similar characteristics as a console window and then redirect the console output from the application(s) being run to append to that sub-window. For more information on how to do redirect the console output in Windows, see http://support.microsoft.com/kb/190351.
That "dos window" is a regular edit control: CreateWindow(ES_MULTILINE, EDIT, ...
However, it has the font set to a fixed-width one (Looks like courier). This is done by sending WM_SETFONT to the edit control.
#user995048 says "You cannot embed a real console window inside another window". But "cannot" is a strong word! I can run an entire virtualized computer in a window if I wish. :) So one can quite reasonably intuit that there are ways of doing what you say.
Sure, it is true that what you've seen are almost certainly cases of output redirection into a custom widget, designed to mimic the simple appearance of a terminal. However...if you want to embed one application's window inside another, there are things you can look into which might fit. Cooperative methods exist like GtkPlug, for instance:
http://developer.gnome.org/gtk/2.24/GtkPlug.html
To actually capture a not-designed-to-cooperate app's window and throw it in your app would be trickier. But possible, just as screen captures and virtual machines are possible. Probably best to avoid that sort of thing unless there's really a cause for it, though...
Try this
http://www.codeguru.com/cpp/misc/misc/article.php/c277/
link. I think the solution provided is what you need.
I tried it many years ago and it worked. I have not tried it in newer versions of windows though.

Unobtrusive Windows Notifications

I'm looking for a simple solution to create an unobtrusive notification program for windows using c++/QT/WinAPI/SDL or any other quick library. I'm wondering what the fastest method (as far as development goes) to create a simple program that pops a quick window up with access to a larger gui interface if clicked.
Is there a quick and easy way to set something up like this?
You may want to have a look at Growl for Windows.

Portable way to hide console window in GLUT application?

Hey, I'm creating a little GLUT application and need help with hiding/removing the console window.
I am developing on windows and I already know of the various methods to hide the console window on a windows system, however is there no portable method of hiding it?
Thanks...
You don't really want to "hide" the console window. What you want is to configure your compiler to generate a "Windows application" instead of a "Console application". That will tell windows to never create a console for your application. You'll need to consult your compiler's documentation to figure out how to do that. For Visual Studio, it is a step on one of the wizards.
There isn't really a good way to control the console inside of a console application. The console is designed so that the application knows nothing about it. While it is possible, as you said, it's not very portable or clean.
The correct approach if you need fine-grained control over the "console" is to implement your own window which provides a text output area where you can print things. Then you can do pretty much anything with your "console" because it isn't really a console, it's just another window owned and operated by your application.

Implementing my own print preview?

I have developed my own Report Control which is simply nothing but drawing text on a CDC of the control window's client DC. I have got the printing function to work too. The report output is sent to the printer directly. However I want to let the user know the output before the report is actually printed.
I cannot do this using MFC's print preview architecture as my project is not using the doc/view architecture. Is it possible for me to create a print preview window myself ? How does MFC handle this ? Are there any special processing need to be done or keep in mind when showing the printer output on screen ? I've read that MFC used 2 DCs for print preview purposes. Do I need to do this as well if Im goin for a custom print preview ?
Your input is highly appreciated !
tia.
P.S. i use Visual Studio 6 and there is no option to change this to a newer version just as there is no way for me to add doc/view support.
Print preview isn't that special. It just means that you have to render to screen (or bitmap) what you'd otherwise would render to the printer DC. This primarly means using the page size, and providing a UI control for the prev/next page.
I had tweeked this code in order to compile it as static lib. It is for dialog based applications.If you don't need special functionality it will work ok for you.
I had to dig through MFC mechanisms to add extra functionality but at the end I dropped it. If you know other programming languages, try to find a print preview control in that language, make it a dll and use it from your MFC application.
For example, I found the NicePreview control for Delphi and it worked, for me, beautifully !
if you managed to print your output to a file in an RTF format and displayed it on screen would this solve the problem?
There is a class CPreviewView in MFC. Maybe you can find a way to instantiate it without MDI structure.
Otherwise, you can simply paint on screen whatever you are painting on the printer DC. Just remember that you will probably need to scale it down for lower dpi.