|
I have placed a gif animation Control(Gif89) in my Dialog based application and in a thread i tried to move the gif's control (with a loaded picture) through the bottom of my Dialog using Move Window() function.A delay of 1ms is introduced between successive calls to move window. I use a timer to communicate with an external device connected to serial port. It takes almost 3 seconds to finish communication. During this time my thread seems to be strucked and gif control is not moved over my main dialog.How can i avoid this?.
the code in the thread for moving control is given below
int offsetx=0;//65
int offsety=444;
int step=0;
while(killthread)
{
m_santa.MoveWindow(offsetx+step,offsety,159,76);
Sleep(1);
step=step+1;
if(offsetx+step>483)//314)
step=0;
With regards
Shibu
"Help yourself through helping others"
|
|
|
|
|
Firstly, Sleep() does not have anywhere near 1 ms granularity. Sleep(1) will sleep for about 50 ms probably.
But what's causing the apparent hang is that (I'm guessing here, CMIIW) the thread did not create m_santa , the main thread did. Since messages for a window must be handled by the thread that created the window, MoveWindow() ends up doing a SendMessage() to the main thread, to have it move the window. SendMessage() does not return until the message is processed.
But since the main thread is busy doing your serial port comm, it is not running its message loop. Thus you have a deadlock, the main thread is busy, and the 2nd thread can't continue until the main thread is done being busy.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Well...depending on the operating system 'Sleep()' will sleep between 10 (Single CPU Windows NT) milliseconds and 50 milliseconds (Windows 98).
I do not know of the top of my head whether Windows 2000 or XP have better resolution...
Ciao, Andreas
"Software is like sex, it's better when it's free." - Linus Torvalds
|
|
|
|
|
Is there a rule of thumb as to when new code should be put into a new class when including a header.
Let say I need to use
#include extrastuff.h
in theory I could make it a new class but if I'm only using one function or proc from it, it then seems a waste of time. If I'm using multiple stuff from the header it makes sense.
Any better logic welcomed.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
Simple - if the group of functions together represent a logic object or partitioning of logic, then they should be a class.
A class called 'CExtraStuff' is a bad idea, use a namespace instead.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
Simple - if the group of functions together represent a logic object or partitioning of logic, then they should be a class.
I am realising I have been using classes for behavior partitions instead of logic, maybe I should change.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
Hi forum
well this is my problem my project involves sending messages to a directx or an OpenGL application i have used SendInput it works for all the normal windows and it even worked for a small OpenGL demonstration game but games like Need for Speed and others do not respond to the keys that i send so anyone with any knowledge of how to deal with the situation
Thanks in advance
|
|
|
|
|
Hi there...
I like to do something, let me describe it with "create a dialog in another dialog".
I currently have a dialog with some controls. I want to reuse this collection of controls in another dialog too. Instead of creating everything again, I like to reuse my controls and it's controling code (object orientated design).
So I thought about a kind of dialog or "child control" that takes a dialog resource (where I arrange my controls) and put it in the middle of a existing dialog.... there it should act like a single control. Well, I hope I could describe what I mean.
Example: An exitsing example close to what I want to do is a property sheet. A property sheet takes AFAIK a dialog resource with a bunch of controls and you can put that inside a dialog (and do even more stuff).
Thanks for pointing me into the right direction! Sorry if I sound like a baby trying to code GUI, my knowledge of Windows GUI is poor.
|
|
|
|
|
You can embed a dialog in another one.
You create the embedded dialog as modeless in WM_INITDIALOG handler as a child window of the main dialog, then set it's size and position.
I use an unvisible placeholder control in resource editor to define size and position of the embedded dialog inside the main one.
Some code (MFC, m_nesteddlg is a CDialog derived class):
void CLineLinPrtPage::CreateNestedDialog()
{
m_nestdlg->Create(m_nestdlg->GetID(),this);
CRect r;
GetDlgItem(IDC_PLACEHOLDER)->GetWindowRect(&r);
ScreenToClient(&r);
m_nestdlg->SetWindowPos(NULL,r.left,r.top,r.right-r.left,r.bottom-r.top,SWP_NOZORDER | SWP_NOACTIVATE);
m_nestdlg->EnableWindow();
}
Pavel
Sonork 100.15206
|
|
|
|
|
thanks, sounds interesting!
Can I ask what for you used it.. what have you done with your nested dialogs?
|
|
|
|
|
Context sensitive part of a form.
You select a communitication protocol in the main part and get protocol specific parameters in the nested parts.
Also when a new protocol is added, only the nested dialog needs to be created.
Pavel
Sonork 100.15206
|
|
|
|
|
thanks
|
|
|
|
|
hi
i have a main Window. and i have some CWnd Objects in it. when i am moveing mouse over the main window the OnMouseMove in the main window is work properly. but even i go over that CWnd object the OnMouseMove of the main windows don't work any more.
how can i Define OnMouseMove for Each CWnd Objects ? or How can i Disable OnMouseMove for each CWnd ? or how can i Set Focus that the CWnd Childs don't get Focus anymore!
|
|
|
|
|
one way is useing this function : CWnd* SetCapture( );
but it locks all buttons and other Windows.
How can i set that the Childs don't get Focus anymore ?
|
|
|
|
|
How can I use a CFormView in a CDialog...
it should be like a "child control" of the dialog. Thanks!
|
|
|
|
|
|
okie... I try to describe what I want to do( rather then using some expressions I don't understand). I'll post a new message "Dialog in a Dialog"
|
|
|
|
|
Nishant S wrote:
A CFormView is actually a dialog inside a view and now you wanna put this inside a CDialog eh? Geez!
yes but it has scrollbars when you make it too small to show everything. Can you use a CFormView as a standalone dialog?
|
|
|
|
|
hi guys, I have a CALLBACK function whose prototype is LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lparam);
how do I get the ProcAdress associated with this function, I tried:
HOOKPROC hookproc = (HOOKPROC)GetProcAddress(NULL, "MouseProc");
and
HOOKPROC hookproc = (HOOKPROC)GetProcAddress(hInstance, "MouseProc");
both returned 0. what's the right way of doing it?
thanks a thousand
|
|
|
|
|
It looks as though you are trying to get the address of a function within your current project. If so, just:
HOOKPROC hookproc = MouseProc;
If it is in another module, then you should call GetModuleHandleEx() before calling GetProcAddress(). You need a valid HMODULE to pass into GetProcAddress().
Cheers
|
|
|
|
|
thanks that helped. I have another question: how do I get a mouse_pressed_down message in my MouseProc function, I can get the mouse coordinates, I want to be able to detect a press on the desktop, not on any particular window. would you provide me with some details? thanks
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lparam){
MOUSEHOOKSTRUCT* mousehook=(MOUSEHOOKSTRUCT*)lparam;
POINT p=mousehook->pt;
char temp[20];
sprintf(temp,"mouse position is %d %d\0",p.x,p.y);
MessageBox(hWnd,temp,"",MB_OK);
return -1;
}
|
|
|
|
|
If you mean a message like WM_LBUTTONDOWN, just look for it in the wParam of your MouseProc. Regarding hooking the desktop window, I have only hooked app windows, so I recommend you tinker to find out. It might be useful to know that the desktop is the absolute top of the window hierarchy, and has no handle (many functions take a NULL hWnd to signify the desktop). Beware that it seems you might have to do global hooking to accomplish this, which should not be done for extended periods, as the entire system would be negatively affected. Don't be surprised if you have to reboot several times while experimenting!
Cheers
|
|
|
|
|
Hello!
Maybe somebody know method to create VS.NET-like docking windows and toolbars using standard
windows controls or COM-objects. I know, that explorer-bar is a COM-object. That's why I suppose that this windows and toolbars could be a COM-objects.
Thanx!
|
|
|
|
|
|
Hi all,
I'm using SAPI 5.1 to develop a text-to-speech application. What I want to do is to be able to asynchronously output spoken text to a wave file and to be notified when that wave file is finished being written. I have set up an event handler using the following calls (with error checking removed):
m_pVoice->SetInterest(SPFEI_ALL_TTS_EVENTS, SPFEI_ALL_TTS_EVENTS);
m_pVoice->SetNotifyWindowMessage(hWnd, UWM_TTSEVENT, 0, 0);
The m_pVoice variable is of type CComPtr<ispvoice>. In order to speak to a wave file, I use a CComPtr<ispstream> object that is bound to a file.
I am able to receive events whenever I call m_pVoice->Speak to speak text to a default audio device. However, if I want to speak to a wave file, the UWM_TTSEVENT message never gets fired.
The thing is, I need to know when the file is completed so that I can close it and clean up, and I need to be able to speak to multiple wave files at once.
Is this a SAPI limitation?
Thanks!
--Two Magic Lovers
|
|
|
|