|
Dear Rutger,
Try your suggestion, got the same error. Seems it's not easy to cheat the compiler.
---------------------------| Error Info |---------------------------
c:\MyClass\MyEx.h(614) : error C2039: 'SetNumElements' : is not a member of 'vector<unsigned int,class std::allocator<unsigned int> >'
c:\MyClass\MyEx.h(649) : see reference to function template instantiation 'int __cdecl HelperFunc(class std::vector<unsigned int,class std::allocator<unsigned int> > *,unsigned int)' being compiled
--------------------------------------------------------------------
Below is the code I used, Maybe you can't point out my errors.
template <class T> static HelperFunc(T* pProjection,UINT32 uNum)
{
pProjection->SetNumElements(uNum);
}
template <class T>static HelperFunc(vector<int>* pProjection, UINT32 uNum)
{
pProjection->->resize(uNum);
}
Inside my template class:
template<class Type1, class Type2, typename Type3> MyFunction(......)
{
...
HelperFunc<Type2>(pProjection, uNum);
...
}
|
|
|
|
|
What's wrong with this?
PostMessage(WM_COMMAND, MAKEWPARAM(IDC_LIST1, LBN_SELCHANGE), (LPARAM) m_hWnd);
error C2064: term does not evaluate to a function
MAKEWPARAM is causing this but I can't see something wrong with it.
Thanks,
Arjan.
|
|
|
|
|
Still don't know why MAKEWPARAM is not working but fixed it
with
WPARAM wParam = (LBN_SELCHANGE << 16) + IDC_LIST1;
PostMessage(WM_COMMAND, wParam, (LPARAM) m_hWnd);
Arjan.
|
|
|
|
|
You are not including the header file that defines that macro, or have some macros set that excludes the definition of it.
Compiler flag /P is your friend.
|
|
|
|
|
|
I already tried that but it had the same effect
I will check my compiler options now.
|
|
|
|
|
How do i get the size of a button or a static text.
Assuming i have a class that is a subclass or a button/static text.
I can get the size of this control by GetWindowRect let's say in OnPaint();
But the position returned by the GetWindowRect in OnPaint gives the position and size
according to the actual whole screen.
How can i get the position and size relative to the dialog box?
void CMyButton::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetWindowRect(&rect);
// Do not call CButton::OnPaint() for painting messages
}
CMyButton is a subclass of CButton.
The purpose of this is to create a control that has a size determined by metric like mm rather than pixel. Thus making the control look the same size on all resolution.
Anyone? being looking around for the proper command.
Thanxs a billion in advance
|
|
|
|
|
I must use the GetClientRect() instead GetWindowRect()
Best regards,
Eugene Pustovoyt
|
|
|
|
|
How can i get the position and size relative to the dialog box?
Just offset the rect with the parent windows window rect.
But, if you just want to draw your "window", what's wrong with the client rect???
|
|
|
|
|
Use ScreenToClient .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
ah thanxs mike i think u got the answer.
the problem with GetClientRect is that it returns the size of the control and not the position of the control.
The position of the control will be returned as 0,0
Thanxs again guys. will try out mike's solution.
And why did'nt i think of that.
Thanxs guys
|
|
|
|
|
the problem with GetClientRect is that it returns the size of the control and not the position of the control.
Is that a problem for your example? If you are only interested in it during painting your paint HDC is the screen area clipped to your HWND and is offset to make the HDC (0,0) be your HWND's (0,0).
|
|
|
|
|
void CMyButton::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetWindowRect(&rect);
CButton::OnPaint();
// Do not call CButtonn::OnPaint() for painting messages
}
void CMyButton::PreSubclassWindow()
{
CRect rect;
GetWindowRect(rect);
CButtonn::PreSubclassWindow();
}
hmmm.. why are they returning different result for rect?
OnPaint returns (222,228,283,412) which is the location with respect to the whole device screen
PreSubclassWindow returns (33,88,14,143) which is the location with respect to the dialog.
wat's wrong???
|
|
|
|
|
I am currently workin on a a little card game. I am interested in making the model of the game so general that I cna reuse that code on other platforms. But right now I am developing the game using Visual C++ so naturally I get text data from the GUI as CString.
Now my question is this. Is there an easy way to convert from CString to std::string? And furthermore is this worth wasting time on or should I rather decide to just change the code to use std::string when I try to port it?
|
|
|
|
|
Well, I think you're better off working with CString s as for the GUI part, since MFC won't handle std::string s in some critical areas (DDX being the most important, probably.) The rest of the code (i.e. the logic and engine) can be written more portably with std::string s. To convert from one to the other, you symply write:
CString cstr;
...
std::string stdstr;
...
stdstr.assign(cstr);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
CString test;
std::string test2 (test);
if you would like to have a program which works well with CStrings, std::strings and char arrays the best is that you pass all the var's as const char* (LPCSTR in windows if you prefer this).. all of them can be casted to a const char* (CString and char - array implicetly, the std::string with the c_str() member function)
if you need to change a string value in a function, use
* a char array (you can use this on any platform, including mfc)
* a std::string if you don't car bout the mfc..
i've heard that there should be some CString ports to other platforms.. but i don't know anything else bout this...
hope this helps a little bit otherwise ask a little bit more detailed..
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Thanks for the feedback.
I also committed the crime of posting a programming question in the Lounge.
|
|
|
|
|
This is what I actually need:-
1024 bit public key/private key encryption
It should run on Win 98, 2000, (and maybe even XP)
Are there any C++ libraries that offer this?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Crypto++ has about anything you'd ever want about criptography, it's free and simple to use --we used it for a project and it works like a charm.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Crypto++ has about anything you'd ever want about criptography, it's free and simple to use --we used it for a project and it works like a charm.
Thanks Joaq. I hope it works in Win98. I am gonna chk it out anyway! Right now I am struggling with PGP SDK
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Managed to download an old SDK.
I find a lot of Key Ring management functions. But they all say that the keys are read and written from the user's keyring. Does this mean that to use te PGP functions, the target machine must actually have PGP installed? I thought if I just distributed some DLLs things would work fine
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Keyrings are simply files, one for public keys and another for private keys.
|
|
|
|
|
markkuk wrote:
Keyrings are simply files, one for public keys and another for private keys.
How do I tell PGP where to look for these files?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Is it possible for an Application B to remove a systray icon installed by another application A. If so how?
Thanks
|
|
|
|
|
One option (the right thing to do) would be to kill application A and possibly force a refresh of the systray.
Another option would be to kill Explorer.exe if it doesn't manage to kill itself somehow. But then when it restarts you would of course have no app-specific tray images.
|
|
|
|