|
I cannot figure out a way to get the WndProc as a member function of my window class I am building. Any Suggestions?
QMuffs
|
|
|
|
|
Do you mean you're designing your own C++ framework for encapsulation of Win32 windows?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, I'm designing my own. It has to do with the hidden 'this' argument that is passed to member functions of a class. It gives me this error.
Compiling...
cWindow.cpp
c:\projects\cwindow\cwindow.h(86) : error C2440: 'type cast' : cannot convert from '' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
None of the functions with this name in scope match the target type
Error executing cl.exe.
cWindow.exe - 1 error(s), 0 warning(s)
QMuffs
|
|
|
|
|
Use static member functions
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Would that make the call to it unique to that instance? If not, how could I make it unique.
QMuffs
|
|
|
|
|
Thank you for your help.
QMuffs
|
|
|
|
|
As you pointed out, the problem lies in the hidden this parameter. One usual workaround to this goes as follows. Store the this parameter into the internal data kept by HWND s with SetWindowLong(hwnd,GWL_USERDATA,reinterpret_cast<LONG>(this)) and set as your window proc a static function that merely recovers the this parameter and forwards the call to the real, per-object window proc:
class cwindow
{
cwindow(HWND hwnd)
{
SetWindowLong(hwnd,GWL_USERDATA,reinterpret_cast<LONG>(this));
}
static LRESULT CALLBACK stub_WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
cwindow object=reinterpret_cast<object*>(GetWindowLong(hwnd,GWL_USERDATA));
return object->WindowProc(hwnd,uMsg,wParam,lParam);
}
LRESULT CALLBACK stub_WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
...
}
}; Get the idea?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for your help
QMuffs
|
|
|
|
|
All documented SC_ values (wParam of WM_SYSCOMMAND) have zeros in the lowest 4 bits. But I sometimes receive this message with lowest four bits of wParam set to 0x2. For example when I doubleclick the caption of an MDI child window, I SOMETIMES receive 0xf122 instead of 0xf120 (SC_RESTORE). May I consider these values valid system commands ?
Is that behavior ever platform independent ?
|
|
|
|
|
Windows sends data internally in the fields that you are not supposed to use. So I would consider it valid.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
|
Hi Guys,
I want to write text to a text file in a specific format ast follows:
Exchange Result
-------- ---------
FOREX 1
NASDAQ 0
LSE 1
Basically I want to write text in 2 columns the setting the width of each column
Any ideas appreciated
|
|
|
|
|
printf("%s\t%d\n", string, value); ???
Is there an environment variable about the TAB so that you can set it, to make sure the second column start at a specifed place?
|
|
|
|
|
Interpretation of the TAB character depends on the program used to view the output. Using spaces is better, but even then the file must be viewed using a constant-width font (e.g. Courier) to see the columns correctly.
|
|
|
|
|
Thanks Lucy
I will give the printf a shot
I am not sure off the top of my head about the environment variable thing but I can do a bit of digging on this.
Cheers
Xtorpia;)
|
|
|
|
|
Another option would be to specify widths
"%-20s %d"
That would left justify the string and space fill to 20 characters.
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?
|
|
|
|
|
iostream s were designed just for this kind of stuff. The following is hopefully self-explanatory:
#include <iostream>
#include <iomanip>
using namespace std;
static void stock_row(const char *exchange,int result)
{
cout<<setw(10)<<left<<exchange<<setw(6)<<right<<result<<endl;
}
int main(void)
{
stock_row("FOREX",1);
stock_row("NASDAQ",0);
stock_row("LSE",1);
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks Joaquín,
This looks like a pretty good solution for wjat I want.
Cheers
Xtorpia;)
|
|
|
|
|
Hi,
We have an big ugly monolitic project, that takes a big while to compile ( and just some minutes to link), and we don´t have time to chop it now in smaller pieces .
But... we have a lot of free computers, my question is... It´s possible to tell Visual Studio to compile some files in one computer, some other in another... ( for example, from A to F, from F to T, from T to Z...) ? ( the the charge is distributed and it would compile it all in parallel).
Is it possible ? Thanks in advance, greetings
Braulio
|
|
|
|
|
|
Braulio Díez wrote:
my question is... It´s possible to tell Visual Studio to compile some files in one computer, some other in another
Not that I am aware of, but you might be able to manually have multiple systems (each running a copy of DS) building separate parts of the project. You would just have to watch out for dependencies, and make sure all computers are in time-sync.
As a small suggestion, is your project correctly using pre-compiled headers?
Peace!
-=- James.
(Try Check Favorites Sometime!)
|
|
|
|
|
Hi,
It´s a pity, I think it´s a problem that more than one company have had to face off... The main problem from our project is that it contains 350-400 files ( it began long time ago..., and like all the things, it was not thought that it would go so far ).
I think we make a good use of precompiled header, the problem comes when we touch some ".H" files, then VStudio has to recompile it all, and that's a pain in the ass... ( you can see A...B...C..... .... .... .... ... ... Z).
Thanks for your help
Braulio
|
|
|
|
|
Hi,
I have two variables of SYSTEMTIME.. how can i check
their difference.. actually i want to check whether
they have a difference of 2 seconds or not
Sameer
|
|
|
|
|
If you're using MFC you can create two CTime objects from your SYSTEMTIME s, subtract the other from the first and use CTimeSpan::GetTotalSeconds()
|
|
|
|
|
I have used 2 FILETIME objects like this before with the function:
FILETIME current_time ;
FILETIME start ;
::GetSystemTimeAsFileTime(&start) ;
Sleep(100) ;
::GetSystemTimeAsFileTime(¤t_time) ;
double elapsed = CalculateElapsedTime(&start, & current_time) ;
double CalculateElapsedTime(FILETIME *start, FILETIME *current)
{
double elapsed_time ;
__int64 st ;
__int64 ct ;
__int32 *p ;
p = (__int32*)&st ;
*p++ = start->dwLowDateTime ;
*p = start->dwHighDateTime ;
p = (__int32*)&ct ;
*p++ = current->dwLowDateTime ;
*p = current->dwHighDateTime ;
elapsed_time = (double)(ct - st) ;
elapsed_time /= 10000000.0 ;
return elapsed_time ;
}
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|