|
Hello,
i got a question about the procedure that receives the messages of an application that is confusing me a lot.
Up to now, i have always seen that messages were received in an application via its window, and its windowproc(...). That window proc also receives the input messages... And that's one of the things i find strange, because an application could just use the mouse or the keboard, without having a window.
I admit that inputs have to be asociated with "something" to determine what application has the focus, but an application without window could (for exemple) be activated by a left mouse click on an icon in the tray, and unactivated by a right mouse click anywhere on the desktop...
Well, my question should be something like "can i explicity set a kind of mouseproc(...) ?"
Lets go, another one (; : is it possible to separate the mouse, keyboard and window procs into three separate callbacks, each one receiving the asociated messages ?
Thanks in advance,
Lion.
|
|
|
|
|
First question. Message procs are always associated with a window, so in general you must have a window to be able to process any message. The only exception (I know of) are messages intended to a thread: those are submitted by windows in the context of a thread (i.e. created within that thread) and consumed by the thread itself. These special messages are distinguised by having NULL as their associated HWND parameter. The most prominent example is WM_QUIT (see <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/messques_0tgl.asp">PostQuitMessage</a> .)
Second question. You cannot separate events based on the classification you propose. For one, some messages can be triggered both by keyboard and mouse action, like the clicking on a button.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks Joaquín,
couldn't i achieve that using hooks ?
or hooks are made for other things ?
Cheers,
Lion.
|
|
|
|
|
Oh, didn't think about hooks... Well, maybe hooks can make the difference, you're right. I'm afraid I'm no expert on such things, maybe someone else here can answer you more authoritatively.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
...that VC7 doesn't support normal C++ programming. All I hear from people is that they don't want to do managed code or NET so they aren't going to get VC7.
Well, I have been using VC7 for a month now and haven't had to WRITE ONE LINE of managed code or NET code. If you don't want to program for NET, then don't. But that is no reason not get VC7.
There are a few good reasons not to upgrade, but not wanting to have NET forced on you is not one of them.
RANT RANT RANT RANT RANT
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
and better standards support, with more to come, is a good reason for C++ programmers to upgrade.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Luckily, I have been using STLPort, so the changes to better standard support didn't hurt me. I had my software built using VC7 in 2 hours.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I hear that the debugging support has been improved.
One nice feature is support to debug multiple applications in one instance of the IDE.
Also the way that MFC and ATL have been changed in order to make the CString a little more compatible between the two frameworks.
There are other features that I have heard of, but I have not yet had the chance to use it first hand.
|
|
|
|
|
I have a crap-load of memory leaks (embedding the Python interpreter is a blast...) and I need to set a breakpoint so the code breaks when data at a certain memory location has changed.
It looks like I can do this in the Edit/Breakpoints/Data tab, but it won't let me set this as a breakpoint:
(int) *((int *) 0x12345678)
Any idea why? Any idea how to do this?
J
|
|
|
|
|
Ok, I no longer want to do this. I found a better way.
J
|
|
|
|
|
Hi,
I have a 2 pane splitter wnd (bottom and top) in an SDI app. I wanna make the bottom pane of constant size (let's say: clientrect width x 100, and the top pane: clientrect width x (clientrect Height - 100).
I tried to handle WM_SIZE in bottomview and topview first calculating the required rects and then calling MoveWindow, without any success. (the panes were not repainted, so the underlying desktop was seen in them)
Could you give me please some pointer how to do it properly?
Thanks
R.
|
|
|
|
|
I am doing this in a current project... try this:
you need a member variable of your splitter window, for instance m_MySplitterWnd.
and in your main window add a WM_SIZE handler
void CYourMainWnd::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
if( nType != SIZE_MINIMIZED )
{
int iCyCur=0;
int iCyMin=0;
int iCyNew=0;
CRect ClientRect;
// get size of client window
GetClientRect(ClientRect);
// is the splitter valid?
HWND hWndMySplitter = m_MySplitterWnd.GetSafeHwnd();
if( hWndMySplitter == NULL || !::IsWindow( hWndMySplitter ) )
{
return;
}
// get and set row info for splitter
m_MySplitterWnd.GetRowInfo( 0, iCyCur, iCyMin );
iCyNew = max( iCyMin, (ClientRect.Height() - 100));
m_MySplitterWnd.SetRowInfo( 0, iCyNew, iCyMin );
// force the splitter to recalculate
m_MySplitterWnd.RecalcLayout();
}
}
Hope this works, it's working for me..
Sef Tarbell
"A mind all logic is like a knife all blade, it makes the hand bleed that wields it." --Rabindranath Tagore
|
|
|
|
|
Well I am almost ashamed of asking this...
After striving to understand ATL/WTL/and brand new COM interface from Redmond...
#include <cstdio>
#ifndef __cplusplus
#error Ok, now you are sure that its cpp.... Disable Language extensions ... no
#endif
int f()
{
return 10;
}
int main()
{
int n = f();
char s[n];
}
My Documents\Visual Studio Projects\test\main.cpp(15) : error C2057: expected constant expression
Am I missing something??? Did I not understand a word of the C++ standard? Did I forget to turn on a obscure switch buried somewhere? I know that it is not valid C, but I thought it *was* :? valid C++...
The code below compiles fine on gcc 2.95.3, but I am aware that the GCC compiler has some extensions to everything...
Please clarify,
Regards,
R.
|
|
|
|
|
You're not missing anything. The offending line is simply illegal: in C++ (and in C) arrays must be declared as having constant (i.e. knowable at compile-time) size, except if you allocate them dynamically
char *s=new char[n]; which might not be what you want --it incurs the extra burden of managing dynamic memory. A good combination of these two extremes (contanst-size stack allocation vs. dynamic allocation) is STL's vector , which allows for non constant-size allocation and keeps you away from the error-prone memory management issues.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
PS: The code presumably compiles in gcc as this compiler is supersmart and can deduce that f(n) is a constant value, namely 10. It is a striking fact that it's allowing this, however (and I think it's not standard anyway).
|
|
|
|
|
Joaquin,
Gracias por la respuesta.
Not exactly....
I am aware of the "new" approach
In the char traits template:
/usr/include/g++-3/std/straits.h
static char_type* move (char_type* s1, const char_type* s2, size_t n)
{
char_type a[n];
size_t i;
for (i = 0; i < n; ++i)
assign (a[i], s2[i]);
for (i = 0; i < n; ++i)
assign (s1[i], a[i]);
return s1;
}
Is an example.
According to the array help in VCStudio
decl-specifiers dname [ constant-expressionopt ] ;
So I can understand why the code does not work. However, it is quite shocking that in the STL implementation of the GCC compiler they use this feacure
I do not have the STD here, so I cannot answer ly own question..
R.
|
|
|
|
|
It is in fact quite shocking the piece of code you're showing. To me, this is just illegal. Why don't you go and post this to comp.lang.c++.moderated? There're plenty of C++ gurus out there who know every minute detail about the standard.
There's a copy online of an old C++ standard draft, which I guess serves most of the time as a valid reference (at least for aspects that have remain stable since long). Follow this link for the paragraph defining constant expression. In particular, there's an illuminating sentence that says
"In particular, except in sizeof expressions, functions, class objects, pointers, or references shall not be used, and assignment, increment, decrement, function-call, or comma operators shall not be used"
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Variable length arrays are a part of C99 standard. You give here a sample code for gcc 3, which support this standard. The C++ prog. language from Microsoft implements a different standard.
|
|
|
|
|
HI
Can any one help how me to create the skin for sound station
thanks and reards
BSR
BSR
|
|
|
|
|
What is sound station ? An example of code for a skinnable app is on CP, just search for mpeg.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Hi,
My question is about this following code :
char ** ValeurColonne;
ValeurColonne = (char **) malloc(sizeof(char*) * 10);
memset(ValeurColonne,0x00,sizeof(char*) * 10);
for (i=0;i<10;i++)
strcpy(ValeurColonne[i],"Some text");
First question :
How can i use new operator to replace malloc ?
Second question :
This line strcpy(ValeurColonne[i],"Some text"); seem correct but i don't understand why we can write ValeurColonne[i]. I think that ValeurColonne isn't an array.
thanks in advance
|
|
|
|
|
- Yes you can. In your particular case the replacement would look like
ValeurColonne = new (char *)[10]; The deletion is done with
delete [] ValeurColonne;
- The line is not entirely correct (except if one assumes there's additional code not showed here).
ValeurColonne is an array, namely an array of char * . That is, each element of ValeurColonne is a pointer to char .Then your line is semantically equivalent to
char * pChar=valuerColonne[i];
strcpy(pChar,"Some text"); The bug in the code is this: strcpy assumes that there's some allocated space pointed to by pChar where the string copying can be performed. As your code stands, pChar is null for all the positions of ValeurColonne , and a crash in your program is guaranteed.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am currently designing custom wrappers of ADO objects for a series of related MFC projects.
Each wrapper is just a generic C++ class with simple functions that hide much of the ADO property/method complexity. ADO objects are interfaced through #import directive.
While carefully studying the structure of *.tlh file, I noticed that all the member functions of smart pointer wrappers are __stdcall type (like Win32 API), whereas the default setting in my MFC project is __cdecl. Then I understand that smart pointer functions will be __stdcall, whereas all of my wrapper functions will be labeled __cdecl during compilation step.
Questions:
1) Do I need to explicitly label each one of them in code with __stdcall as well, or __cdecl callers of __stdcall methods do not interfere with each other?
2) Does anyone know when when exactly is it preferred to overide __cdecl with __stdcall?
3) What are the advantages of one calling convention over another?
Thanks.
Kirill
|
|
|
|
|
1) There's no interference at all. You can invoke a function having whatever calling convention from any other function with different calling convention as long as the caller knows in advance the proper calling convention of the callee.
2) 3) Nemanja Trifunovic's Calling Conventions Demystified explains it all about CCs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Just one add to the previous reply : _cdecl is the only one that allows variable argument lists.
|
|
|
|
|