|
Hi!
Hope I'm not to much trouble.
I'm kind of new to this so thanks for all the help.
DavidCrow wrote:
Huh? LANGUAGEGROUP_ENUMPROC is a typedef from winnls.h.
I hope I understand this right:
How do I use this typedef?
LANGUAGEGROUP_ENUMPROC EnumProc; (like this ??)
Then declare the callback function:
BOOL CALLBACK EnumProc(
LGRPID LanguageGroup,
LPTSTR lpLanguageGroupString,
LPTSTR lpLanguageGroupNameString,
DWORD dwFlags,
LONG_PTR lParam
)
{
return TRUE;
}
Then send this to EnumSystemLanguageGroups:
EnumSystemLanguageGroups(EnumProc, LGRPID_INSTALLED, 0);
Is this how it is supposed to be used??
I read a remark in the page link you gave me;
This function can carry out any desired task. An application registers an EnumLanguageGroupsProc function by passing its address to the EnumSystemLanguageGroups function.
I'm really new to all this, so please explain in details.
Thanks!
|
|
|
|
|
Hachaso wrote:
How do I use this typedef?
LANGUAGEGROUP_ENUMPROC EnumProc; (like this ??)
Not necessary.
Hachaso wrote:
Is this how it is supposed to be used??
Yes, just like the code snippet I provided.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
How to share a variable between two classes?
Please give me a answer.
Thank you very much!
|
|
|
|
|
Could you be a little bit more specific ? What you mean exactly by sharing ?? Because you can have a lot of interpretations to that...
|
|
|
|
|
I would just use pointers from one class to the other. Then you can easily work on the other class' variables.
Or point to a common structure or something like this.
|
|
|
|
|
If you mean that you want to share a variable among several instances of the same class, just make the variable (I assume that it is a member variable of the class) static..
Behind every greak black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
By sharing if u mean the availability of the variable declared in one class in another, then there are two ways of doing it.
Lets say u want variables of Class A in ClassB
1)The first way is to include the header file of that ClassA into ClassB. Create an instance of ClassA and use the variables of ClassA in ClassB.make the constructor of ClassA to be public. But this contradicts the very meaning and concept of OOP. By doing this any class can create an instacne and use them to access the variables.
2)Make ClassB to be a friend of ClassA. By doing this ClassB can access the members of ClassA and no other class can do it.
hope this is what u were looking for...............
|
|
|
|
|
Define a instance of class A.
the instance can access to a variable of class B.
could I let class A inherit class B?
|
|
|
|
|
Hi everyone,
I have included C code which offers me a lot of hard coded "extern" callbacks.
My question is: Can I encapsulate these into some kind of class?
Currently I have just many of my functions for the callbacks, but to use data arround in many of the callbacks I have to use them kind of global, and I do not really like this.
Can I set the pointers for the callback to functions that are part of a class (or my instance of it)?
Let's take an easy example that would be comparable: You want to get callbacks into the current dialog's CDialog object. You receive a string and want to show it on the dialog. Would be silly to have a global handle to the window and to use this. Or to have a global string variable if another callback should work with it later on.
Could you not set a callback pointer to one of it's functions in a way like CP_Action=this.myFunction(), so I have not to mess arround?
Or can I at least bring some straightness into it without using classes? Suggestions would be great.
Thanks in advance!
|
|
|
|
|
No, callbacks cannot be in classes, they must be global.
The reason is very simple - when you use a callback function you use it's address and the address cannot exist until there is an instance of the class plus the instance of the class cannot exist until it has been created during execution.
Elaine
The tigress is here
|
|
|
|
|
Trollslayer wrote:
No, callbacks cannot be in classes
Callbacks can be in classes as long as the function is static . By making the function static you are effectivly making the function global.
As for member functions check out:
http://www.codeproject.com/cpp/FastDelegate.asp
This will give you a good idea of how member function pointers (which are my determination callbacks anyway) work.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Uff, a lot to read in the article about the member function pointers...
But I think this is exactly what I was searching for! Thanks a lot.
Kind regards,
Roland
|
|
|
|
|
|
Hi,
I used property sheets to display some texts. When I click the OK button then the function is normal - i.e. the dialog box closes normally. However if I press 'Enter' key to close the dialog box, I notice that the dialog box closes, but also sends a WM_KEYUP message. Is there any way I can avoid this?
I want even the 'Enter key' to function like clicking the 'OK' button.
Also I would like to know if there is any method to trace the messages? Everytime I try to it goes to the MFC source program which i dont desire.. I want to trace in my program itself.. is it possible?
Thanks.
ani
|
|
|
|
|
How would a WM_KEYUP message affect the scheme of things? Also note that when you click the OK button you do get the WM_LBUTTONDOWN and WM_LBUTTONUP messages.
|
|
|
|
|
Hi,
then what is the difference between clicking OK button and pressing the ENTER key? In the sense, I call this property sheet from a parent window. So after clicking OK or CANCEL in the property sheet, it closes and returns back to the parent window. Does it still carry the WM_LBUTTONDOWN OR WM_LBUTTONUP to the parent window? Also, what message is sent when pressing the ENTER key instead of clicking OK button directly? bcos these two seem to call different procedures in my case..
Thanks
ani
|
|
|
|
|
By default, pressing the enter key has the effect of clicking the OK button. You needn't worry about the mouse/keyboard messages that are sent. Similarly, clicking the ESC key has the effect of clicking the Cancel button.
|
|
|
|
|
Add OnOK and OnCancel Handlers in the dialogs (propertypages) to call the OnOK and OnCancel of their parent ( i.e. the PropertySheet ).
Rahim Rattani
|
|
|
|
|
In my property page, I call PropertyPage::OnOK() in its OnOk() function. I guess this will take care of the Property sheet onok?
Is there any method where I can prevent VK_RETURN to be passed on to the active window after the dialog box closes? This happens when i press Enter key to activate the OnOK() of the property sheet/page.
Since this VK_RETURN message is also passed on to the active window after destroying the property sheet, the data in the active window gets disrupted as though someone had pressed an enter key there- though they havent actually....
Any solution?
ani
|
|
|
|
|
does anybody know how to convert from "CString" to "LPCWSTR" ?
i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as
HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName);
i wish to pass CString taken from the user interface to the BITS function. didn't get much help from MSDN
|
|
|
|
|
I found MSDN to be quite informative.[^] Don't forget to call ReleaseBuffer when you finish with it.
I take it back, you're trying to create a wide string. Try this[^] instead.
A _bstr_t will convert between narrow and wide strings for you ( by using these macros ), but is not of much use otherwise.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
The easiest way would be to compile you program to use UNICODE strings.
In Project - Settings - C/C++ : Preprocessor definitions
make sure _UNICODE is defined and not _ANSI or _MBCS.
This will make CString use wide chars and allow an auto cast down to LPCWSTR.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I tried to install opengl and glut on Visual C++ on dotnrt 7.1. I searched the net and did exact;y what they said, but seems like it is not working . It is really frustrating, anyone has any idea what is going on and how I should install it?
|
|
|
|
|
Hi everybody. Here's an easy question for anybody that started learning Visual C++ correctly, from bottom to top (not like I did). I want to use GetSystemTime to create a string nicely formatted with the current hour. Unfortunately, I'm totally wasted with Visual C++ string manipulation routines. Maybe you can give me a hand. I want to use chars. Here's what I got so far.
SYSTEMTIME cmTime;<br />
char *a = (char *) malloc(256);<br />
char *b = (char *) malloc(256);<br />
char *c = (char *) malloc(256);<br />
GetSystemTime(&cmTime);
I presume I could use strcat or some function to concatenate the members of the cmTime SYSTEMTIME structure in a nice string. But so far my attempts resulted only in critical errors and program crashes : D. I suppose this could be done easier using the CString class, but I want to try with this because I could learn more. Also, I think one or two char variables are enough. If you can do this with only 2 of the variables declared, it would be even better.
I would want to do something like this: "HH:MM:SS DD MM". That kind of time format. Anyway, even HH:MM is good, I'll figure the rest out. I just need to know how to work with these strings. Pf. Hard for me, I don't know where to start!
|
|
|
|