|
I dont see this[^] article but I think it has some helpful info for you.
|
|
|
|
|
Hi
We know that Windows keeps a message queue for every thread.
If i am not wrong for win32 applications, only one message loop is enough.
But in MFC applications, we have Message Map macros(DECLARE_MESSAGE_MAP/BEGIN_MESSAGE_MAP/END_MESSAGE_MAP) for every window class. Mainfrm, chidfrm, childview, doc etc..
Do all of the message map macros that we see in the source code indicate there is a message loop that buried in MFC source code?
I couldn't make relation between win32 message handling and MFC message handling.
Thanks...
|
|
|
|
|
sawerr wrote: We know that Windows keeps a message queue for every thread.
Only if you call a function that causes a queue to be created on a thread.
sawerr wrote: for win32 applications, only one message loop is enough.
Yes, one is sufficient, but not necessary unless you create at least one window.
For example, you don't need a message loop in a console app.
sawerr wrote: Do all of the message map macros that we see in the source code indicate there is a message loop that buried in MFC source code?
Yes, but not a separate message loop for each window/class.
There's still one per UI thread. See the source code for
CWinThread::Run() - the per-thread message loop is there.
The CWinApp class derives from CWinThread, so for an MFC GUI app,
your required CWinApp object generally provides the first/main
message loop.
Once messages are extracted from the queue in a message loop, then
they are dispatched to their destination window via a call to the destination
window's windowproc (window procedure). That's basic Windows windowing[^].
The message map table macros generate compiled code that maps a message
received in the windowproc to a call to the appropriate window class method.
Hope that makes a little sense.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
For example if we want to use Edit control in win32 app, the code will be:
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
Here we create a "control". That control has a message loop in its source code which was written by controls developer. If an event happens, it is sent to its module(for example user32.dll) not to our application. It sends to our program a notification.
OK.
But in MFC, We use CEditView which is derived from CView. So we create a new window.
And CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",...) is in the CEditView.
Has that view window got a message loop too?
If no, how can we handle for example WM_CLOSE
void CTextView::OnClose()
{
CEditView::OnClose();
}
You said:
Mark Salsbery wrote: The CWinApp class derives from CWinThread, so for an MFC GUI app,
your required CWinApp object generally provides the first/main
message loop
If view window has a message loop, is that mean it is created by a new thread?
For example, When user close this CeditView window, is this message sent to Main Window or View Window?
If it is sent to main window, does main window route it to view window?
I'm sorry, i really don't solve/understand the mechanism...
Thank you.
|
|
|
|
|
sawerr wrote: Here we create a "control". That control has a message loop in its source code which was written by controls developer.
No, it doesn't. It has a window procedure implemented by the control developer.
You are still responsible for providing a message loop.
You're confusing message loops with window procedures.
Window procs are related to the window class. MFC subclasses windows so
the MFC framework gets first peek at messages before forwarding unhandled
(i.e. no message map entry) messages to the original window proc.
sawerr wrote: If view window has a message loop, is that mean it is created by a new thread?
That doesn't make sense. Windows don't have message loops.
Threads can implement a message loop. Windows have window procedures,
which are functions called by the system to send a window a message.
Study the link I gave you on windowing. It's the fundamentals
of Windows programming, and in my opinion, essential to know and
understand completely to be an effective Windows programmer.
If you need more drawn-out documentation on how it all works, then I
recommend the book "Windows Programming" by Charles Petzold.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: You're confusing message loops with window procedures.
Yes, that's right. And now i understand.
-One loop
-Get Message and
-DispatchMessage finds the right window procedure.
Thank you for help...
|
|
|
|
|
I'm trying to access my eMail contents using a POP3 client app I'm trying to design (something like a simple command line). My eMail Address is testpopid@yahoo.com (I've made it temprarily and will delete it after your answers ). here is my conversation with the server:
telnet pop.mail.yahoo.com 110
<br />
+OK hello from popgate 2.4 ...<br />
USER testpopid<br />
+OK Password required.<br />
PASS MyPassword<br />
-ERR [AUTH] invalid user/password
where "telnet" connects to a server (in this case "pop.mail.yahoo.com") and '110' is the port number used to connect to server.
I use the password I defined when creating the eMail account. When I try to log into my account within my brower, ther's no problem and the above password works (I use www.yahoo.com to log in)
Thank you masters!
|
|
|
|
|
How are you passing your password? Plaintext? I'm not familiar with how yahoo will handle doing logins, but perhaps the password doesn't go in as plaintext?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I'm pretty sure yahoo only allows POP3 access if you're using a paid account.
If I'm right, then yahoo is waiting to verify who you are, looking you up, and rejecting you [*].
Iain.
[*] Don't take it personally.
|
|
|
|
|
I'd like to read a wav file, not using playsound() function. I want to get the wave of the sound and draw them out. Which function can solve this problem? Please give me some tips.
|
|
|
|
|
As cool as your name.
BTW, it may be easy for UNIX, coz everything in UNIX is a file.
logics
|
|
|
|
|
No UNIX Please
Thank you masters!
|
|
|
|
|
followait wrote: BTW, it may be easy for UNIX, coz everything in UNIX is a file.
Is it the joke?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Saturday, September 27, 2008 12:14 PM
|
|
|
|
|
It depends to you.
|
|
|
|
|
I think i saw your answer on the codeproject I think it was for avi files but you can use of its code for wav files.
|
|
|
|
|
Hi all
I need to print all the <b>'Running Applications'</b> in windows(XP/VISTA) using C++, win APIs.
Thanks & Regrads,
Subrat
|
|
|
|
|
Have a look to EnumWindows [^] function.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am using vs 2005.I need native c++ code to perform the same task.
It'd be great if your are telling me how to implement that CALLBACK func which is used in EnumWindows() API.
|
|
|
|
|
Implementing the callback isn't difficult. Anyway, to fullfill your requirements, maybe this example [^] is more appropriate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks a lot for you quick response.
This exmple is for enumurating all processes.I need only Applications those are are displyed in Task Manager->Application tab.
|
|
|
|
|
You could use the tool help library:
#include <Tlhelp32.h>
...
HANDLE hProcessSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE != hProcessSnapshot)
{
PROCESSENTRY32 processentry;
processentry.dwSize = sizeof(PROCESSENTRY32);
if (::Process32First(hProcessSnapshot, &processentry))
{
do
{
TRACE("%S\n", processentry.szExeFile);
}
while (::Process32Next(hProcessSnapshot, &processentry));
}
::CloseHandle(hProcessSnapshot);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I got the soln.Now problem is I want to store all app names inside a container(Vector).And finally calling a function to print it.But that function is unable to print these application names correctly.
#include "vector"
using namespace std;
wchar_t szText[256];//Holds app name
//Print function
void PrintText(vector<wchar_t*> apps) {
for (vector<wchar_t*> ::iterator itr = apps.begin();
itr != apps.end();
++itr) {
wprintf(L"%s \n", *itr);
}
}
vector<wchar_t*> r_apps;
//Inside callback func
bool callbackfn(.....) {
......
......
......
// if printing szText using wprintf() it is printing the app names correctly.
//using vector to store all these app names
r_apps.push_back (szText);
}
//Main func
int _tmain(int argc, _TCHAR* argv[])
{
.......
.......
PrintText(r_apps);
return 0;
}
PrintText() is unable to print the app names correctly.
My o/p comes like below:
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
// If using wprintf() above 'r_apps.push_back (szText);' statement then o/p come like belows.
C:\WINDOWS\System32\cmd.exe
AppPrint - Microsoft Visual Studio
CodeProject: Visual C++ / MFC Discussion Boards. Free source code and programmin
g help - Mozilla Firefox
Registry Mechanic
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
?????????????????????????↕?A?↕?A?↕?↕??????????????????????????
Please help me in this regard.
|
|
|
|
|
I can't tell what you're doing in that code, but it
looks like you're adding the same wchar_t* to the
vector every time, and there's no valid string data
being pointed to.
If you're going to store wchar_t pointers in the vector, then you
need to allocate a separate buffer for each string and copy each string's
contents into the new buffers.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This program will display all the running processes but not the application names those are displayed by Task Manager->Application.
Another q. is to use TRACE what header I will have to include.
|
|
|
|
|
A search ffor "list running processes" yields lots of info.
For example: this one[^]
Member 4708266 wrote: to use TRACE what header I will have to include.
Diagnostic Services (MFC)[^]
I just used that as a test example - you'll probably need to output
to someplace more useful.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|