|
For a GUI application you need to think in terms of what you do to react to user input, not the classical main approach. As such, do not think of your dialog application as having a main code section - your application responds to messages from the Windows message system, and it is within the handlers for these messages that your application code is distributed as appropriate. In the case of drawing a circle in the window, then you would put that code within the handler for the WM_PAINT message, for example, which is called whenever the window needs to be redrawn. If you bring up the ClassWizard then it allows you to define a whole host of these functions to respond to most things. To stress, dont think of it in terms of having a main code section - Windows handles all that, you just respond to its messages.
|
|
|
|
|
Johnny is exactly right.
Windows (like any event driven GUI) requires your application to respond to events. Windows notifies your application when an event occurs by sending messages to its windows. Each message is identified by a WM_something constant. Examples of messages are:
-
WM_SIZE the user has just resized the dialog
-
WM_MOVE the user has moved the dialog
-
WM_QUERYENDSESSION Windows is shutting down and would like to terminate your application
-
WM_PAINT the user has moved a window, causing (part of) your window to need to be redrawn MFC conveniently provides predefined methods (that you can override) to customize your response to these messages. The one you probably want to handle is the last one. The handler for this message is OnPaint() .
My gut tells me you might be better off doing some reading before venturing into building your app. Once you get a better handle (pun intended) on MFC, you can decide where to inject your application's drawing code and perhaps add more bells and whistles to your app.
Good luck!
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Right now, I am doing quite bad in C++ programming class, and I really have no clue how to start this program. All I need is a kick in the rear (psuedocode), I obviously don't need anyone to type out the code for me.
http://www.cse.psu.edu/~cg103/NewHW/Pj2.pdf
A quick note: The due date is incorrect on there. It is due Tuesday November 18th.
Thanks for your help. I really, really appreciate it ^_^
|
|
|
|
|
You're just talking about setting up 2D arrays and passing over them, aren't you ? To flip, you swap values across one row or column at a time, and to add brightness, you need just add a value to each element, up to a maximum of the max grey specified in the header.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am a novice to C++. I am writing a program where I need to get today's date in this format (MM/DD/YY). I also need to know the day of the week (Sunday - Saturday). I have looked for this information on the CodeProject site, but all I found were things I do not understand. Is there a command, function, etc. I can use in my program that returns the information I want? Or do I have to learn more about C++ to understand the information contained on this web site. I hoped this would be easier. Thanks for you help in advance.
David Hoffman
|
|
|
|
|
|
Thanks Mike,
Sorry but I don't have a clue as to what you are saying. I have not worked with structures or classes, just functions. I have only been in a C++ classroom for about 3 months. In BASIC this was easy, DATE$ gave you the date and then you could manipulate it. I don't want you to write the code for me. Can I look at code that is already written and be able to understand it so I can then modify and use it in my program? Everything I have seen so far has been confusing because I have seen no explaination of what is happening. For example, I found this snippet of code in Visual Studio C++ that displays the information I need, but there are places in the program that I do not understand. Here it is.
#include <stdio.h><br />
#include <sys/timeb.h><br />
#include <time.h><br />
#include <iostream.h><br />
<br />
void main( void )<br />
{<br />
struct __timeb64 timebuffer;<br />
char *timeline;<br />
char wait;<br />
<br />
_ftime64( &timebuffer );<br />
timeline = _ctime64( & ( timebuffer.time ) );<br />
<br />
printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] );<br />
cin >> wait;
}
Would you explain this program to me so I can umderstand what is going on, or can you guide me to where I can read something that explains what is taking place? Thanks again.
David Hoffman
|
|
|
|
|
Easy (when you know how)
You need to look up the ftime and ctime functions in your IDE help.
The fact that you have _ftime64 and _ctime64 functions makes me think you're working on a 64-bit system, not a 32-bit one. How am I doing so far?
ftime retrieves the time, and then ctime converts it into a string (like DATE$).
The printf just splits the last part of the string off, so your output contains hundredths of a second.
Steve S
|
|
|
|
|
Hi,
I have a dialog in which I have a toolbar in the middle of the dialog window. I put the toolbar there with a
m_wndMiddleButtons.SetWindowPlacement(&wpl)
in OnInitDialog. m_wndMiddleButtons is a CToolBar and wpl is a WINDOWPLACEMENT structure.
I have to move this toolbar in the OnSize method of my dialog, but when I can (from OnSize)
m_wndMiddleButtons.SetWindowPlacement(&wpl) my app crashes. I can't call any method of m_wndMiddleButtons without a crash.
Anybody nows a method for solving this problem?
Thanks.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Let's say the user didn't click the OK-button (or any other button) of the MessageBox dialog. Is there a way to define that MessageBox dialog is still running?
Or let's put in another way - for some reasons I need to show my application above all the other non-topmost windows, but I can't do this when the MessageBox/AfxMessageBox dialog is running - for example when the user didn't click on the OK button of the MessageBox dialog and has activated another application. What shall I do in order to show my application and the unclosed MessageBox dialog? Is there a way to define that MessageBox dialog is still running? Or is it possible to create a pointer to it? And what about AfxMessageBox dialog - can I create a pointer to this dialog?
|
|
|
|
|
|
Hi.
How can I Toggle views?
I use SplitterWnd (2x1), and want to toggle view in pane(0,0).
I made button for toggle, andthen, using flag for setting current-view state.
But, can't redraw view.(because that's Split-window?)
Followings: in this I use 2x1 and 1x2 splitterwnd.
CRect rect;
GetClientRect(rect);
if(!m_wndSplitter1.CreateStatic(this,2,1))
return FALSE;
m_wndSplitter2.CreateStatic(&this->m_wndSplitter1, 1, 2, WS_CHILD | WS_VISIBLE, m_wndSplitter1.IdFromRowCol(1,0));
m_wndSplitter1.CreateView(0,0,RUNTIME_CLASS(CDvMenu),CSize(rect.right,58),pContext);
m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CDvView),CSize(rect.right/2,rect.bottom),pContext);//pic viewer
if(flag != 0)//flag for current view state
m_wndSplitter2.CreateView(0,1,RUNTIME_CLASS(CDvOpenGL),CSize(rect.right,rect.bottom),pContext);//opengl viewer
else
m_wndSplitter2.CreateView(0,1,RUNTIME_CLASS(CDvView),CSize(rect.right,rect.bottom),pContext);//pic viewer
SetActiveView((CView*) m_wndSplitter2.GetPane(0,1));
return TRUE;
~~~
void CDvMenu::OnToggle()
{
// TODO: Add your control notification handler code here
CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CDvDoc* pDoc = (CDvDoc *)pFrame->GetActiveDocument();
BOOL toggle = ((CMainFrame*)pFrame)->flag;
if(toggle)
((CMainFrame*)pFrame)->flag = 0;
else
((CMainFrame*)pFrame)->flag = 1;
-------------> Here, what should I do? plz, help.
}
|
|
|
|
|
You should call CFrameWnd::SetActiveView().
|
|
|
|
|
Hi.
I'm trying to write a program that would act like a banner. Here are the requirements:
. sit on a screen edge (top, bottom, left or right)
. restrict all other windows to the part of the screen not used by the banner
. run under Win98 and above
. should be written using Visual C++
I have no idea on how to limit the other programs to use the area of the screen not covered by the banner. Any help ?
thank you
Milonius
|
|
|
|
|
What you're thinking of is an app bar. Check out MSDN as there are a few pages on writing them. I've also seen articles in past MSDN magazines with MFC code for writing them too.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
My project needs to split a 20 page pdf file to 20 single page pdf files, I don't have any clue in doing it, could anyone help me in accomplish it, thanks in advance.
|
|
|
|
|
or: is it a bug?
We develop with .net 2003 & develop services.
Services run a long time, and occasionally crash.
We are having a heck of a time getting DrWatson to work for us. He was our friend, before we moved onto C++ .NET2003 but seems not to like us anymore.
Anyhow, we're clueless on the matter.
I'd like to know your strategy for dealing with an application that needs to be up and running all the time, and when it crashes we need to record it and restart it.
Anyhow, once we started to use .net/2003 we lost this. We never used the first .net either.
We need to automagically record dump files and be able to interpret later.
Help!
Thanks in advance.
P.S. Ship day in 2 days.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
|
|
Hi,
In this situation I would use the SetUnhandledExceptionFilter API to set up an exception filter and then within your exception filter function you can use MiniDumpWriteDump to write a dump of your problem service. You can then open the mdmp file up in VS.NET press F5 and you will be at the point where your program crashed.
Hope this helps
Ceri
|
|
|
|
|
Hey y'all....
Thanks for the info. We ended up going for the auto-minidump thingy. We like this since it doesn't matter whether DrWatson is installed....
Anyhow, thanks, 2 days to ship, and we've got one more weapon for finding crashes!
Thanks.
P.S. If you wanna beta test our stuff -- High-class audio/video/text/appsharing from a windows client -- come visit our beta site www.videomonkeys.com[^]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Does anyone know how to make this in assembler, you know using the asm partialy in the c++ file:
#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
main()
{
int a = 1;
int b = a+1;
int c = b+1;
int d = c+1;
int e = d+1;
int f = e+1;
time_t start;
time_t end;
time(&start);
for (a=1;a <= 47;a++)
{
for (b=a+1;b <= 48;b++)
{
for (c=b+1;c <= 49;c++)
{
for (d=c+1;d <= 50;d++)
{
for (e=d+1;e <= 51;e++)
{
for (f=e+1;f <= 52;f++)
{
// cout << setw(8) << a << setw(8) << b << setw(8) << c << setw(8) << d << setw(8) << e << setw(8) << f <<endl;
}
}
}
}
}
}
time(&end);
system("cls");
cout << "started:" << ctime(&start);
cout << "ended:" << ctime(&end);
system("pause");
return 0;
}
I only need the looping in assembler.
NOTE: DON'T DO THIS IF YOU DON'T WANT TO!!!
OR IF YOU DON'T HAVE TIME!!!
Old United Airlines Brochure:
If you cannot read this please ask a superintendent to help you... LOL, for real!!!
|
|
|
|
|
Why Assembler?
The performance problem is the endl. They are very slow since they also flush the IO stream.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I just want to know how much faster is assembler.
Old United Airlines Brochure:
If you cannot read this please ask a superintendent to help you... LOL, for real!!!
|
|
|
|
|
Due to the i/o, any performance increase in assembler will be negligable. For simply logic like you're doing, a performance increase is unlikely. It may actually be slower due to lack of pipeline optimization.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|