|
waldermort wrote: I you take away digits from a phone number, how can your auto redial work? The same applies here.
Renaming the function is just like a speed dial, 1 for your mother, 2 for the bar. The telephone still dials the correct number.
Err, this is quite confusing...
|
|
|
|
|
Thanks or all answers
waldermort wrote: A callback is like an auto redial on your telephone. Each time something happens, a timer has looped, a specific message is sent... The callback function is called.
But i want to learn its mechanism.I explained how i imagine it in C#.I wrote function, I register it with its delagate.And when event occurs "windows" call my function.
But in win32 i wrote in WinMain GetMessage().So it takes message feom queue and call specific func.So function is called my program itself not by windows.
Is this true?If true this is not callback right?If wrong what is the mechanism of win32 callback.I hope i can explain my problem more clear now.
Thanks
|
|
|
|
|
Using GetMessage() is similar to a callback, but by definition it is not. When using a callback function, you first create the function, then pass a pointer for it to another function. For example SetTimer() . The last paramater of SetTimer() allows you to enter a pointer to a function, so each time an event happens (you timer finishes counting) it calls the function.
What you have created is a 'message trap'. When a certain message is there you call your own function.
If you have a user defined message, why don't you just add a handler for it in your WndProc() ? When using GetMessage() and PeekMessage() it is usually to perform an action before the message is processed. For example, trapping keyboard key presses.
-- modified at 4:14 Thursday 7th September, 2006
|
|
|
|
|
I think the main problem you have is to understand WHO calls the Callbackfunction. You give the pointer to a function to windows and Windows will call this function when it gets a message for that window (or did you implement you own GetMessage, TranslateMessage and DispatchMessage functions?)
The usual way to program it is having the loop in WinMain repeat GetMessage TranslateMessage and DispatchMessage calls these functions get one message from the global queue, translate it to make something useful with it and call the WndProc. And exactly that call cannot be influenced by you, it is programmed in the Windows API.
Giving the function pointer at registering is like telling a friend "if anything happens send a mail to this address". When you alter the signature of the function (by changing count, type or order of the parameters) this function is definitely not of the same type that Windows can call as Windows needs a function with 4 parameters. It's comparable like giving out a mobile phone number instead of the expected email adress.
I don't know C#, but i I think there too exist rules for defining event routines, so I don't think you can assign a function that needs 5 arguments to a button click event, or can you do that?
Greetings
Martin Dietz
|
|
|
|
|
I need to call a console application passing it information via CLI.
How is that data passed in? I know it's retreived through args, argc...
Are they internally stored in environment variables? or passed in using streams???
Most Importantly:
=================
Whats the buffer capacity when using the command line? Could I pass buffers as large as 10MB or so using the CLI?
Storing the data in a file and opening that file isn't an option...I need actually pass X number of bytes via the command line. Or a process which is cross platform friendly (Windows/Linux)
Cheers
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
The strings are passed in as char*, basic c type strings. I remember reading somewhere about a 1024 byte limit on the command line, but I cannot find anything on MSDN to support this, so I may be wrong.
I really wouldn't pass a 10mb like this though. Why is using a file not an option? Why don't you look at memory mapped files, which can use the system pagefile, though the calling format is different on linux.
|
|
|
|
|
It's hard to explain why files are not allowed, but basically it's because the caller is written in PHP, executed on linux. PHP has to pass a variable data input, which I would have to first create some randomized file name, worry about file locking, etc...
It'd be much easier to just pass in a buffer. :P
I'll have to re-examine the situtation I guess...as I was sure there was a limit on CLI buffer sizes
Cheers
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
|
I think he meant Command Line Interface, not C++/CLI
|
|
|
|
|
|
I'd look at using something like shared memory - you can then use the argc/argv parameters to pass an address or token to access it.
Named Pipes would also be a good solution I think.
There are plenty of cross-platform implementations for this...
...unless you're passing information between Windows and Linux in separate processes. Then you will probably either have to create a file. If you wanted to go to a little more trouble maybe using TCP sockets would work?
|
|
|
|
|
Hi,
What about using the WriteFile method?
See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/writefile.asp">http:
Only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
You need to a question!?
|
|
|
|
|
Hi,
I am writing a wrapper for a DLL that has 2 functions:
int func1(long p1);
int func2(char *p1, ...);
The wrapper creates pointes to the two functions:
int (* pfunc1)(long p1);
int (* pfunc2)(char *p1, ...);
To call function 1 I do: wrapper.pfunc1(1234);
My problem is: how do I call func2 using the pointer? Sometimes I may pass 1 parameters, sometimes 2 or 3 or 4, and the data types may change.
Is it possible at all to do this?
Thanks
|
|
|
|
|
yaron klodovski wrote: how do I call func2 using the pointer?
same as you are using pfunc1.
yaron klodovski wrote: Sometimes I may pass 1 parameters, sometimes 2 or 3 or 4, and the data types may change.
you need to assign address of function having prototype same as function pointer.
i.e. function may look like this
int foo(char*,int);
or
int foo(char*,char*,int);
|
|
|
|
|
I wrote a usb mass storage driver and installed it for a special application.
When the driver exists in the system, USB Mass Storage device can not be recognize and the device should be installed manually. It's OK.
But when I would like uninstall the driver by a simple program, the driver can not be uninstalled cleanly some times.
Is there a better solution?
Thanks for your kindly comments.
Best regards.
|
|
|
|
|
Hi,
I want to dynamically created CListView and handle its events, I derived CFileList from CListView and overridden methods like this:
void CFileList::OnNcLButtonDown(UINT n,CPoint p)
{
GetListCtrl().InserItem(0,_T("any thing"));
}
void CFileList::OnLButtonDown(UINT nFlags,CPoint point)
{
AfxMessageBox(_T("Mohammad");
}
and it doesnt seem to work.. so whats the problem??
Note: I am using embedded VC++ 4.0
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
See if this helps.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I'm currently working on a singel project witch includes many threads. There will be one class which implements the input and output. Next to that, there will be a single object (GLOBAL!) which stores information.
more specific, both the IO class and the threads will communicate with the global storage object, so where to declare it?
The application is fully written in C++ and totally OO
Thanks already!
Koen B
|
|
|
|
|
In your case, implement the global data object as a Singleton class. Whenever you want to use the object, call the specific static method to get its instance. It does not matter where you declare it first.
Best,
Jun
|
|
|
|
|
thanks, i've declared one static object already and used the extern keyword in nearly every file. but i see yours is better
|
|
|
|
|
when i use :
AddString(W2CA(pImageCodecInfo->MimeType)
when compile W2CA these error occur:
f:\visual sutido project\ImageProcessing\ImageProcessing\ImageProcessing\ImageProcessingView.cpp(257): error C2065: '_acp' : undeclared identifier
f:\visual sutido project\ImageProcessing\ImageProcessing\ImageProcessing\ImageProcessingView.cpp(257): error C2065: '_convert' : undeclared identifier
...
is that need some extra include files?
MJM.
|
|
|
|
|
mostafa_pasha wrote: AddString(W2CA(pImageCodecInfo->MimeType)
You are missing a closing parenthesis and a semicolon. Is that intentional?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
excuse me about my fault whole code is:
CPropertiesDlg Dlg;
ImageCodecInfo imgCodecinfo ;
UINT num;
UINT size;
ImageCodecInfo *pImageCodecInfo;
GetImageEncodersSize(&num, &size);
// Create a buffer large enough to hold the array of ImageCodecInfo
// objects that will be returned by GetImageEncoders.
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
GetImageEncoders(num,size,pImageCodecInfo);
for (UINT j =0; j< num ; j++);
Dlg.m_ListBox.AddString(W2CA(pImageCodecInfo->MimeType));
Dlg.DoModal();
|
|
|
|
|
mostafa_pasha wrote: Dlg.m_ListBox.AddString(W2CA(pImageCodecInfo->MimeType));
You cannot add to a listbox that does not yet exist.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|