|
If you don't handle a message, you should be calling [edit]DefWindowProc()[/edit] to allow Windows to perform default processing for the message. In your case, the problem is probably because Windows doesn't get a chance to handle WM_NCLBUTTONDOWN or WM_NCHITTEST , so it doesn't have a chance to allow the user to move the window.
[edit]Sorry, don't use DefDlgProc() from inside your dialog box procedure. Infinite recursion followed by a program crash will probably result. Use DefWindowProc() instead[/edit]
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Look at what your dialog proc is doing when it receives WM_MOVE . It does nothing, then returns true , which means that you handled the message. Since you did nothing, nothing happens. Return FALSE instead to let the system do the default behavior for that message.
BTW, the dialog proc return value is a BOOL , not bool . This is important for messages that return more than just a flag such as WM_CTLCOLOR*
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
I even hear the Windows "OMG I booted up fine" sound.
-- Paul Watson diagnosing hardware problems.
|
|
|
|
|
Hi Everybody,
I developed an application Using Embedded VisualVC++ 4.0 and Windows CE.
In my application, I would like to add Rounded Shape or any irregular shape dialogs.
In Windows2000 most of the functions support the same.
Can anyone know to make a dialog as rounded shape in Windows CE?
Please answer my question.
Thanks inadvance,
pandi.
|
|
|
|
|
Just create a non rectangular region and assign it to the CDialog window...
Since CreateEllipticRgn is not supported on Windows CE you`ll have to create rounded shaped regions yourself by combining rectangular regions.
I did it in a Win32 application I designed in Windows CE4.0 for an ARM device and a MIPS device and it worked beautifully! Offcourse it isn^t MFC but I guess the procedure is the same!
Greetz,
Davy
|
|
|
|
|
Hi Davy,
Thanks for your reply.
How can i create rounded shaped regions by combining rectangular regions?
Please answer to my question.
Thanks inadvance,
Pandi.
|
|
|
|
|
void DW::OnSubmit()
{
typedef char INFO[225];
INFO ALL[6];
CFile UTP;
CString k;
CEdit *GTINFO[6];
GTINFO[0]=(CEdit*) GetDlgItem(IDC_EDIT1);
UTP.Open("C:\\az.qiz",CFile::modeReadWrite|CFile::modeNoTruncate);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++GET TEXT+++++++++++++++++++++++++++++++++++++++++
GTINFO[0]->GetWindowText(ALL[0],(GTINFO[0]->GetWindowTextLength()+1));
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++WRITE TO FILE+++++++++++++++++++++
k.Insert(k.GetLength()+1,ALL[0]);
k.Insert(0,"\r\n");
UTP.Write(k,k.GetLength());
MessageBox(k,"test",MB_OK); //this worked
///}
}
|
|
|
|
|
Man, your commenting style is damn ugly.
None of this code does any checking, it all just assumes that it works. In the absence of any comments as to what happens when it fails, it's kind of hard to help.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
You've not provided any useful information. For example:
What doesn't work?
Does it compile/link okay?
Are any assertions fired?
Are any exceptions thrown?
Have you stepped through the code to see which line is in error?
What value(s) do the variables have as you step through the code?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
GTINFO[0]->GetWindowText(ALL[0],(GTINFO[0]->GetWindowTextLength()+1));
That's one weird line of code ....
what exacly you want to do ? get the text from all CEdit and write them to to a file ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
get the string from an edit box and write it to a line in a text file
|
|
|
|
|
why don't you simply call CWnd::GetWindowText( CString& ) ?
seems you are complexifying things a wee bit ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You mast write, won won't work in you code (if you debug it )
For fist look, the general error in that lines :
ANDYFA wrote:
k.Insert(k.GetLength()+1,ALL[0]);
k.Insert(0,"\r\n");
wht you want to do : insert string on 1-st position in zero length string , and then prepend it whith CRFL
Try this:
k += CString(ALL[0])+CString("\r\n")
|
|
|
|
|
Hi,
I have a gui application. Originally the application is written such that all of the processing is done when you receive the OnIdle message. The performance was adequate and both the GUI and the process got enough resources such that the interface worked ok. I decided that it made more sense to move the processing from OnIdle into a separate thread in order to improve performance of the user interface. Unfortunately the opposite happened. Now the GUI is almost dead.
Here's a model of my program:
<br />
UINT Hog(LPVOID p)<br />
{<br />
CThreadView * me = (CThreadView *) p;<br />
return me->MyHog();<br />
}<br />
<br />
UINT CThreadView::MyHog()<br />
{<br />
int x = 0;<br />
while(1)<br />
{<br />
x = x*x;<br />
}<br />
return 0;<br />
}...<br />
AfxBeginThread(Hog, this);<br />
...<br />
First, that's a model, that's not my processing function. Second, there is A LOT of performance improvement if the thread is allowed to run without calling this->Invalidate(). But I need to update the graphical user interface based on what the thread has done. That is I need to repaint the CView.
I've also used SendMessage() (yes I'm aware of deadlock possibility) and PostMessage() to run a function in the "main" thread that just calls this->Invalidate. The performance sucks as well.
I don't have any critical sections/locks on the data so I don't think anyone is waiting.
Any suggestions?
|
|
|
|
|
Can't you just update the GUI in OnIdle as you did before?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Any time you spin in a tight loop in a worker thread, it will suck up as much CPU time as the system will give it. Look in Task Manager and you'll see the CPU pegged.
And since that thread is doing so much work, it ends up posting a ton of messages to the main thread (via Invalidate() , which generates WM_ERASEBKGND , WM_NCPAINT , and WM_PAINT , maybe others too). Since the thread is hogging the CPU, the main thread can't process those messages as quickly as if the thread weren't running.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Ford, what's this fish doing in my ear?
|
|
|
|
|
First of all: lower the priority of your worker thread. Any thread that will take a long time to process data should be low priority so that it doesn't interupt anything else you might want to do while waiting. (such as play a game!) This will at least make sure your GUI thread isn't interupted when it need to do something.
The idea is that for any process that takes a long time, it makes little difference in the long run if other processes interupt it. However, for interactive processes (which normally don't take a long time to run) anything else running will slow it down. So you make your worker threads low priority and it has little effect on them, while it makes the rest of the system seem faster! This comes from scheduler theory, but most CS programs don't require a class that would cover it.
Some ideas: I don't know which is best, if any. Some are sub optimal. Some might not even work.
Instead of sending events, just have your GUI thread repaint on a timer every second.
Have the GUI thread wait on a semophore that your worker thread normally hold. This is hard to describe, basicly you need a way to force the GUI thread to wait until the worker thread has done something before it repaints. You might need a third thread to watch the semaphore and send the message, I can't recall how the API works.
Instead of a full repaint, send a message detailing the progress, and just update the parts of the GUI that change based on status.
In the worker thread only update the GUI every 100 (1000? experiment on different machines to find a good number) iterations through the loop.
|
|
|
|
|
Along with the suggestions already made...
Why invalidate the entire window?
Are you udpating a graph? Can you just redraw the part that changed?
Does your data change that fast? If so, maybe you can not keep up with it visually anyway. You will need to show a 'summary' of some form. Or historize the dat and allow user to select which time frame/ranges he wants to view.
|
|
|
|
|
Thank you for all the suggestions. I'm trying out some of them now. Setting the thread priority to below normal helps, but then when I move the mouse or interact with the gui the thread almost doesn't do anything.
To give you more detail the program is actually capturing images using a camera via a firewire cable. With thread having normal priority the images come in really fast, so fast that the user interface is unusable and the images don't get displayed properly.
I redraw using OpenGL, and I no longer call Invalidate() I just call the GL function that draws the image. The performance is still not as good as the balance I have now from OnIdle.
|
|
|
|
|
OK, you guys are always great at helping young aspiring programmers. Here's my situation:
I need to move files from directory A to directory B. If a file being moved from A exists in B, I want the file from A to overwrite the file in B (regardless of date, size, etc.).
I'm planning on using MoveFile to accomplish this. Pseudo code:
while(more files in directory A)
{
Get next file;
If(file exists in directory B)
{
delete file in directory B;
}
MoveFile(from directory A to directory B)
}
Is this the best way to accomplish what I need to do? I'm using MoveFile instead of CopyFile because I want any security attributes that belong to the file to remain and my understanding is that CopyFile does not get the file's security attributes.
If there is a "more right" way to do this, I'd like to know.
Thanks so much!
Ian
|
|
|
|
|
What you have is fine. You may want to look at the SHFileOperation() API as it will handle multiple files at once and can override any existing files in the destination folder.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
have a look at ShFileOperation maybe it will do more than the more simpler MoveFile.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thank you both! I appreciate it. I will take a look at shFileOperation.
-Ian
|
|
|
|
|
Hai,
I'm new to programming...I have to calculate some values in a func and get those values outside the func..
ie i'm doing as below
main()
{
float *val1 = NULL;
float *val2 = NULL;
........
myfunc(&val1,&val2);
myfunc2(*val1,*val2);
.........
}
int myfunc(float *V1,float *V2)
{
int cal1 = 10;
.....
*V1 = cal1 / 2; ---> It does'nt give me any error,but when I debug it gives me access violation in memory 0x0000000 here...
*V2 = cal1 / 5;
return 0;
}
where am I going wrong...
Thanks a lot..
|
|
|
|
|
myfunc(&val1,&val2); means you are passing the address of val1. Val1 is a pointer. Try
myfunc(val1, val2);
Also you need to initialize val1 and val2 to point to something. I hope you did that in the .....part of your main.
|
|
|
|
|
No I did'nt initialize anything..
My basic idea is this..I have to compute the values of two float variables in myfunc1 and use those values in myfunc2.How should I do this..
Thanks a lot
|
|
|
|