|
I have an MDI application which is using CMFCVisualManager and showing nice themes
It also has some dialogs for example About dialog which is not using this theme. Can I apply this them on that? How?
I have VS 2008 + MFC featured pack with some service pack.
|
|
|
|
|
I am trying to be able to send socket commands from a MFC program but my parent window is blocked see the message below.
Is it possible to use fork to start another MFC program?
What is the simplest way to communicate with this programs?
I was thinking to using three files. One that indicates that that data is sent by Master program and another file that is used by Sölave that tells that it is processing data and a third file that data actually is stored in.
Is there a better way to do this I have just a few days to fix this problem on so it should be a simple solution?
|
|
|
|
|
See this message[^] below by enhzflep on the use of threads; it could well be what you are looking for.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Are you sure that this will inhibit the parent window message queue/parent dialog from be blocket? What is the differences beteen create a modeless dialog comared with this thread?
Is there anyone that can explain why a modeless dialog is blocking the parent window. I thought that the moduless dialog was an own thread that did not inhibit the parent process to execute.
modified 19-Nov-11 5:24am.
|
|
|
|
|
Yes, the background thread will run independently of the main window thread so your message pump will continue to run. I am not sure whether a modeless dialog would be better, it all depends on what your program is trying to do.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
The only thing I do is sending out a message by using CSocket/CTimeoutSocket, but if fail to connect to the unit I try to access both the modeless dialog and the parent dialog is blocked.
Is there anyone that can explain why a modeless dialog is blocking the parent window. I thought that the moduless dialog was an standalone thread that did not inhibit the parent process to execute.
What is differences between a background thread and a modeless dialog?
|
|
|
|
|
I am trying to create a program in MFC that talkes to several wireless IP-routers on internet. Now and then will a router be disconnected, and when that happen will the parent window in my MFC program be blocked for a while, which is not acceptable.
The reason for this is that in my MFC program it should be possible for a user to send and receive commands to one of the router while the other routers is supervised (I sending a special command to these router to see if they is still up and running).
The problem is that if one of the routers is disconnected and my MFC program sends out a supervise command to this router will the main window be blocked which means that a user cannot use the parent window for 30 seconds or so.
I have tried to solve this with a worker thread but I could not invoke any CTimeoutSocket from this thread since the MFC program stopped working then.
So I tried to create a hidden modeless dialog and put all the CTimeoutSocket code in this dialog but when a socket is blocked for a while will not only the modeless dialog be blocket but also the parent window.
So have anyone any idea how I shall do to inhibit the parent window from be blocked?
modified 19-Nov-11 3:15am.
|
|
|
|
|
Use non-blocking sockets[^] (i believe the MFC version is CAsyncSocket[^], never used it though).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
**********
*********
********
*******
******
*****
****
***
**
*
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int r=1; r<10; r++)
{
for (int c=r; c>1; c--)
cout<<" ";
for (int j=r-1+1;j<=10;j++)
cout<<"*";
cout<<endl;
}
--------------------------------------
*
**
***
****
*****
******
*******
********
*********
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int r=10; r>1; r--)
{
for (int c=r; c>1; c--)
cout<<" ";
for (int j=r-1+1;j<=10;j++)
cout<<"*";
cout<<endl;
}
return 0;
}
|
|
|
|
|
Read the guidelines[^] before making another post.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Is there a question hidden in your post?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hello
I want to know how can i animate from triangle 1 to triangle 2 that we can see the movements.
i want to know how can i move characters that indicate that they moves.
tnx alot
|
|
|
|
|
:smacks-head: Of course, why didn't I understand that when I first saw your initial post?
Well, judging from your images, they're simply 10x10 blocks, with (the right-hand) 1/2 filled with characters. If you were to assume the windows co-ord system (the one your using when outputting to the console), where by (0,0) is at the top left of the screen, with (width-1, height-1) being at the bottom right you could view the problem like so:
Image 1: draw line from (0,0) to (9,9) - fill in any pixels to the right of this line up to X=9
Image 2: draw line from (9,0) to (0,0) - fill in any pixels to the right of this line up to X=9
You need to animate between the two.
---
(1) Since the block is 10 stars wide, you'll need 10 frames
(2) The middle frame would be - draw line from (4,0) to (4,9) - a vertical line.
Hmm perhaps we could run a 10 iter loop -
iterNum = 0 .. 9
x1 = iterNum
y1 = 0
x2 = 9-iterNum
y2 = 9
FillBetweenAndToRightOf(x1,y2, x2,y2)
endLoop
You'll obviously have to come up with the FillBetweenAndToRightOf function yourself.
Your above tricks won't work when it comes to determining how many spaces to print before you start printing * characters, this time you'll need to calculate the gradient of the line
Recall that gradient = rise/run.
For img1, your X pos varies by 10(from 0-9), as the Y pos changes by 10(from 0-9). Therefore the gradient is 10/10 = 1.
You can then multiply the gradient by the Y pos, add this to X1 to find the first * character on the line. E.g row 4 (0 based) 4*1 + 0 = 4.
For img2, your X pos varies by -10 as the Y pos changes by 10. This time the gradient is -10/10 = -1
E.g row 4 (0 based) 4*-1 + 9 = 5.
Simply draw the figure 10 times with changing values of x1 and x2, using the above formulas to calculate where to start and how many stars to draw on each line.
|
|
|
|
|
tnx alot for your help
i must work on it and tell you again.
tnx
|
|
|
|
|
Rotating on which axis?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
hello
in -X axis
tnx alot
|
|
|
|
|
X-axis meaning horizontal? Are wanting it to rotate top over bottom? Which of the 10 rows (of the triangle) will be the pivot point? How many rotations are there between triangle 1 and triangle 2?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
*********
********
*******
******
*****
****
***
**
*
#include <iostream>
using namespace std;
int main()
{
for (int r=10; r>1; r--)
{
for (int c=r; c>1; c--)
cout<<" ";
for(int p=r;p>1;p--)
cout<<"*";
cout<<endl;
}
|
|
|
|
|
Is there a question here someplace, or do you just randomly post code snippets for grins?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
So I thought I understood the wndproc, in which it loops and listens for WM messages. But I guess if you run a function, the wndproc stops looping until the function stops, and then the wndproc listens again.
So is that where callbacks come into play?. If I run a function, I have to have a callback, that's like a mini wndproc?
Which leads to threads,
If I call a function like downloading a file, I hand off the function process to a new thread, and let that worker do the tasks, and just forget about it until it done or the cancel button is clicked.
Now Threads, I tried this one first.
http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=1273[^]
I'm just lost on how to get the tread working, and test it to see if it really works. I'm missing a big piece to this here
CThread ct;
ct.CreateThread;
sleep for awhile
during sleep, I should be able to click my cancel button -> wndproc capture. Pop a message box off.
done - destoy thread.
|
|
|
|
|
jkirkerx wrote: But I guess if you run a function, the wndproc stops looping until the function stops, and then the wndproc listens again.
True.
jkirkerx wrote: If I run a function, I have to have a callback...
Search for message pump.
For more on threads, see here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks Dave, Will look into the Message Pump,
The Thread lesson looks good.
|
|
|
|
|
Sticking just to threads:
Go to the basics, the Windows API first. The problem with classes is that they help you but you have to do it the way the class author wanted it done. That doesn't help you learn threads, only gives you some magic to make it work. Personally I hate magic and need to see behind the curtain.
All you need to start is one function,
long thread_id;
HANDLE h = _beginthreadex(NULL, 0, ActuallyGetStats, NULL, 0, (unsigned *)&thread_id);
and some code with the proper calling conventions
unsigned int __stdcall ActuallyGetStats(void *)
{
return ERROR_SUCCESS;
}
This will run as a separate thread. You can put some code in there to, let say, loop 10 times, sleeping for 10 seconds each time and printing / TRACE() a message saying "I'm alive". You can also set breakpoints in there.
Now you can do some tests on the returned HANDLE in the main code to see if it's done or you can do other things. In my case, that _beginthreadex() call is done when a button is pushed on the GUI, kind of like what you had in mind.
You can also pass parameters to the function that it can use to get pointers to objects that might tell it what to do. That would be in the 4th parameter, which I've set to NULL here because there are no arguments needed.
Anyway, this is the basic start of a thread. It might be easier to play with than figuring out somebody's conventions in a class.
|
|
|
|
|
I must concur on your standing of using other peoples code. That has always gotten me into trouble in the past and the present. That's why I wrote my own IBindCallbackStatus, and did not use the example code, and I fully understand how my code works - The WCHAR issue a couple of days ago.
I'll start 1 statement at a time, and build it up, and look into that message pump that Dave mentioned.
Oh, 1 question, at what point should I start the thread, at button click, or inside the function that is called with button click?
Button Click "Next"
call function - "Prepare" - adjust buttons and artwork, setup progress bar, setup cancel button, check previous
call function - "download" - Start bind callback - start URLFileDownload
Return to window
Thanks Chunk.
|
|
|
|
|
I start the thread in the processing of the button click, in the routine pointed to by ON_BN_CLICKED() entry in the message map.
Where you start yours is up to you but I like to keep the functions of the GUI in the GUI so if you have some "pretty up" work to do, I say do that in the GUI module and then fire up the thread to do the work.
As for the Message Pump, really, I don't think you need to look into that. Basically if the GUI thread is working normally, not freezing while you are doing other processing, etc then it is already using its own message pump and should you should *not* do one yourself. If you move the long running processes into another thread, then the GUI thread should remain responsive.
An alternative message pump is only necessary when you jam all sorts of processing into your message processing routines, like if you tried to do the download inside the routines called when the button was clicked. And, there are folks out there who will say that providing your own message pumps is a hack and should never be done (and you know who you are ) so I'd say hold off discussion on message pumps until you are in the mood to deal with the purists (for the record, I am not one and I do use message pumps when necessary, and no, they are not a hack )
|
|
|
|