|
It sounds like you really want a multi-threaded application.
Cathy
Life's uncertain, have dessert first!
|
|
|
|
|
Care to explain? This app is quite multi-threaded already, and the section posting the messages is in its own thread...
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
I thought maybe that was the problem, that you were doing it in the same thread.
I had to do something like this to get my messages through:
<br />
while (theApp.m_pMainWnd && PeekMessage(&msg, theApp.m_pMainWnd->m_hWnd, 0, 0, PM_NOREMOVE))<br />
{<br />
if (!theApp.PumpMessage())<br />
{<br />
PostQuitMessage(0);<br />
return TRUE;<br />
}<br />
}<br />
Cathy
Life's uncertain, have dessert first!
|
|
|
|
|
First, messages sent though PostMessage are not guaranteed to make it through. In practice, however, only in very extreme circumstances (slow machine, fast input) do they not get through.
Also note that PostMessage() will only fail if the window handle is incorrect or some other critical problem. Whether or not the message will be received has no bearing on the success of the call. (See SDK documentation.)
I question the use of a hidden window. I suspect the messages are being reflected somewhere. Why not just use the main window and use USER messages?
|
|
|
|
|
Joe,
Thanks for the info.
I suppose I should've mentioned that the messages I'm referring to come from the WaveOut API, so they cannot be user messages. In particular, I'm handling the MM_WOM_DONE message. (See waveOutProc in the SDK doc, if you are interested.)
The reason I chose to not use the main window was for code maintainability. I am able to keep all of the waveOut code in one or two classes that I can move around as needed, this way. I'm not sure that handling it in the main window will do it either, see below...
You are correct about the messages being reflected, I think. I've noticed that the MM_WOM_DONE message comes through my main message loop and is then dispatched to this hidden class, most of them anyway. (Hence my problem - I'm not seeing all of them here, either.) Based on the way I'm creating the window (see the code in the prior post, parentwnd = NULL), I figured that the messages would come straight to this window,but I guess not.
So assuming that this is the nonUSER message I'm working with, is there a way to get it to post to the queue in my hidden window directly, instead of routing through the main message loop?
Thanks!
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
I have a wave in/out class that doesn't have a problem.
First, due to where the code is used, I don't use MFC when I create the callback window. I also create it with CreateWindowEx with WS_EX_NOPARENTNOTIFY. Here's a snippet from my code:
LRESULT CALLBACK CBWaveCallback(
HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
CBWave *pWave = (CBWave *)::GetWindowLong(hwnd, 0);
if (pWave)
{
switch(msg)
{
case MM_WOM_DONE:
pWave->OnDataOut((HWAVEOUT) wParam, (WAVEHDR *) lParam);
return 0L;
case MM_WIM_DATA:
pWave->OnDataIn((HWAVEIN) wParam, (WAVEHDR *) lParam);
return 0L;
}
}
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
static TCHAR nameBase[] = _T("CBWaveCallback");
HWND CBCreateWaveWindow(
HINSTANCE hInst,
HWND hWndParent,
LONG waveClassThisPtr)
{
TCHAR className[32];
_tcscpy(className, nameBase);
_tcscat(className, _T("Class"));
WNDCLASS wndClass;
if (!::GetClassInfo(hInst, className, &wndClass))
{
wndClass.style = 0;
wndClass.lpfnWndProc = CBWaveCallback;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 4;
wndClass.hInstance = hInst;
wndClass.hIcon = NULL;
wndClass.hCursor = NULL;
wndClass.hbrBackground = NULL;
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = className;
if (!::RegisterClass(&wndClass))
return (HWND) 0;
}
TCHAR windowName[32];
_tcscpy(windowName, nameBase);
_tcscat(windowName, _T("Window"));
HWND hWnd = ::CreateWindowEx(WS_EX_NOPARENTNOTIFY, className, windowName,
hWndParent ? WS_CHILD : WS_POPUP, 0, 0, 0, 0, hWndParent, NULL, hInst, NULL);
::SetWindowLong(hWnd, 0, waveClassThisPtr);
return hWnd;
}
|
|
|
|
|
Thanks for the help! I'll give that a try.
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
Hi,
How can I create the controls CComboBox and CIpAddressCtrl without edges.
Removes a WS_BORDER style has not effect.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Have you tried removing the WS_EX_CLIENTEDGE extended style. You may have to call RedrawWindow with the RDW_FRAME flag to force the change.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you for quickly answer.
I tried create two classes FlatIpAddressCtrl and FlatComboBox .
In the PreCreateWindow method add next line
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
But I still see a edge.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Are you using these controls on a dialog, property sheet, or form view. If so, then apply the change in the PreSubclassWindow() function. If you put a breakpoint in PreCreateWindow() you will find the function is not called.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I tried add to the PreSubcalssWindow method
ModifyStyleEx(WS_EX_CLIENTEDGE, 0);
But it has not effect too
Best regards,
Eugene Pustovoyt
|
|
|
|
|
ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED) or else look in the combobox section here on CP, someone must have written a flat combobox at one time????
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi..
I have this code:
<br />
CMemoryState msOld, msNew, msDif;<br />
msOld.Checkpoint();<br />
<br />
for(int n=0;n<100;n++)<br />
pRoot->Add(10.0,false);<br />
<br />
delete pRoot;<br />
<br />
msOld.DumpAllObjectsSince();<br />
msNew.Checkpoint();<br />
msDif.Difference( msOld, msNew );<br />
msDif.DumpStatistics();<br />
the resulting memory dump:
1980 bytes in 99 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 1732 bytes.
Total allocations: 2000 bytes.
after i made some change to the destructore of pRoot and re-compile i get :
0 bytes in 0 Free Blocks.
-20 bytes in -1 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 1732 bytes.
Total allocations: 2000 bytes.
I don't exactly understand this!!
1st Q : I think I had a memory leak in the first time .. but did I solve it ?
2nd Q : Can you kindly explain what does this memory dump say ?
|
|
|
|
|
FROM SEARCH OF MSDN:
Foundation Class Debug Library Detects Memory Leaks
ID: Q99022
The negative numbers indicate that memory is allocated before the Checkpoint() call...
-----------------------------------------------
CMemoryState::Difference
BOOL Difference(...)
Return Value : Nonzero if the two memory states are different; otherwise 0.
-----------------------------------------------
Visual C++/MFC Frequently Asked Questions
Scot Wingo
Stingray Software
How do I use CMemoryState?
....
It looks like you solved it, but you may want to read the above and possibly read the articles on memory leak detection at codeproject.
I use Bounds Checker for all my validation and compliance testing. Most of the companies, that offer memory checking software, offer a fully functional time limited demo, so that you can shop and compare.
INTP
|
|
|
|
|
Hi Guys , I'm building a class that will help me reduce the code I need to write to get an OGL window up and running , But I've some issue , when I start filling up the Window Class structure , I come to the WNDPROC ,I want to pass the address of a method <member function=""> in the main class , but I get an (error C2440: '=' : cannot convert from 'long (__stdcall OGLWindow::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)) ,I wonder if there's some way I can estblish this kind of converstion , or else I'll just have to write the WndProc function seperate from the class , I hope I'm making sense here , thanks in advance for any help
|
|
|
|
|
You can't put it in a class.
All non-static class functions have a hidden "this" argument, so the function signature won't match with the WNDPROC one.
|
|
|
|
|
See the article:
Use member functions for C-style callbacks and threads - a general solution
INTP
|
|
|
|
|
Hi, I'm writing an mp3 player using DirectShow. I want my player to be able to load some sort of playlist.
To do this, I need a way to specify a search directory, like for instance
c:\mp3\
the mp3 dir would serve like a root directory, storing every mp3 file i got in albume directories.
like for instance:
c:\mp3\albume1
c:\mp3\albume2
c:\mp3\albume3
my application needs to search for directories in the mp3 directory and make a list like the one above.
But I don't know what functions could be used to make this serach possible.
Also, I need a way to search every albume directory for mp3 files.
Could anyone guide me to which functions might do what I need?
thanks alot!!
|
|
|
|
|
FindFirstFile/FindNextFile
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
Hello,
You should use the CFileFind class to do the searching! Use the FindFile() method to start the search and use FindNextFile to retreive data.
exemple:
CFileFind ff;
CList<CString, CString&> dirlist;
dirlist.AddTail(_T("YourMp3Directory"));
do
{
if(ff.FindFile(dirlist.RemoveTail()))
{
while(ff.FindNextFile())
{
if(ff.IsDirectory())
{
if(!ff.IsDots())
dirlist.AddTail(ff.GetFilePath());
}
else
{
}
}
}
}while(dirlist.GetCount() > 0);
hope this helps
|
|
|
|
|
could anyone help me about this ?
for example : my program needs to get the MS WORD's horizontal scrollbar handle and control it.my program needs to scroll the document view on its own in this case.
i had tried these functions include : GetScrollInfo / GetScrollBarInfo / PostMessage but can't get the correct handle.....
tks for ur help !!
have a nice day !!
yoyo
|
|
|
|
|
There are three issues here:
Issue #1: How to get the scrollbar HWND
Using a tool like HPS HwndSpy, you can examine the hierarchy of windows that Word uses. In the case of Word 2000 (Office XP), if you open Word with an empty document, you will see this hierarchy:
"Document1 - Microsoft Word" class OpusApp
"" class _WwF
"Document1" class _WwB
"" class ScrollBar
"" class ScrollBar
(The window titles are in quotes, followed by the window class name).
As you can see, there are two scrollbars, one vertical and one horizontal. It seems like the horizontal scrollbar is always second. So, to find the HWND of the horizontal scrollbar programmatically, simply traverse the window hierarchy for Word, until you come to class _WwB, and then grab the second ScrollBar.
Issue #2: It may not work like you expect
Some programs react violently when you try to send them messages. It may work, or it may not work, or it may cause Word to crash. So before you invest a lot of effort into this, you should first verify that it will work as you expect.
Issue #3: Different versions may be - well, different
You should verify that this technique will work on all the versions of Word that you are interested in. Different versions may have different window hierarchies, and may also react differently when you try to control the scrollbar.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
hello,HPSI, tks for ur answer.
i use while loop with "GetWindow(hChild, GW_CHILD)" and ""GetWindow(hChild_1, GW_HWNDNEXT)" to grap the handle but how can i make MS Word's horizontal scrollbar functional ?
should i use PostMessage or SendMessage ? which handle to input ? parent window's handel (form "OpusApp") ? or parent window's child window's handle (_WwB or _WwG or _WwC) ? or the scrollbar's handle ??
tks for ur help !!
have a nice day !!
yoyo
|
|
|
|
|
hey i wanna know which is the best source online to learn vc++.i'm very interested in c++ and now want to extend my skills.can anyone suggest a good free website or link or a good book?
thanx in advance.....
#include"universe.h"
int main()
{
char *galaxy;
while(1)
{
cout<
|
|
|
|
|