|
Hy everybody!
I made an GUI Dll, and I found a problem...
- When I made my Dialog modeless, the default button doesn't work. It only works if the Dialog is Modal
Why?
cheers!
Ricky
|
|
|
|
|
I need to be able to keep all of the controls of a dialog ( for resize purpose )in a list/vector, ... ; so I use GetDlgItem with the controls ID to retrieve the CWnd of each control; but MSDN says that the pointer is temporary.
I don't want to keep a member variable for each control of the dialog; but this is working and might be a simpler solution.
Is there another way to do this ?
Max.
|
|
|
|
|
I think the pointer is temporary because controls can be created and destroyed dynamically. I think you will be fine to leave it the way that it is.
For safety, you may want to make the OnDestroy handler remove the point for that control from the parent dialog class.
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!
|
|
|
|
|
Declare an array to save all of controls ID like this:
<br />
int ControlIDArray[]=<br />
{<br />
IDC_BUTTON1,<br />
IDC_EDIT1,<br />
IDC_PROGRESS1<br />
};<br />
A. Riazi
|
|
|
|
|
Hello,
I need to use a template function, but I need that that template function be a class member...
Let's say that I've tried to do:
INSIDE THE HEADER FILE:
template<class T> void MyClass::MyFunction(T& Parameter);
-------------------------------------------------------------------
INSIDE THE IMPLEMENTATION FILE:
template<class T> void CMyClass::MyFunction(T& Parameter)
{
SomeOperations...
}
-------------------------------------------------------------------
HOW DO I CALL THE FUNCTION:
bool b = false;
MyFunction(b); The fact is that using this code I get a lot of errors (one in each MyFunction call) like:
...MyFile.cpp(119) : error C2893: Failed to specialize function template 'void __thiscall CMyclass::MyFunction(T &)'<br />
With the following template arguments:<br />
'bool'
The strange thing is that if I remove the declaration from the class (I've commented it out) and I call the function as a non class member, then it executes well...
I need to be able to call that function while that function would be a part of CMyClass.
Is this possible? and if it is possible, what do I'm doing wrong?
Thank you in advance.
NOTE:
Somebody has told me that this is a weakness of the VC++ compiler, but I continue searching because I need it, what do you believe?
|
|
|
|
|
Firstly, the declaration you have there is not correct. ( or is it just formatting which removes the < typename T > bit ? )
Anyways, ( assuming it is not ), to declare a template member function you have to do this;
in header:
<br />
template< typename T > <br />
void MyFunction( T& );<br />
...<br />
template< typename T ><br />
void MyClass::MyFunction( T & param )<br />
{<br />
...<br />
}<br />
The point is that you can't define a templated method outside of the header-file where it is declared. ( The compiler might not complain, even 7 doesn't, but the linker looses it... )
Secondly, this will only partly work if you have anything earlier than VC 7. VC 6 will do it, however it might fail silently on certain cases which can cause you grief later. ( In particular if you try to specialise the member templates )
-=jarl=-
|
|
|
|
|
Sorry, I've corrected the syntax... could you take other look at it?
|
|
|
|
|
...right, so reading, my reply again I realise that it might not be entirely clear....;P
What I was trying to say was;
Member function templates are poorly supported by VC 6
Member function templates are supported by VC 7, however...
Member function template specialisation is not, ( not properly, anyways ),
What you are trying to do, ( splitting template declaration and definition into
separate files ), is the subject of the mysterious export keyword, which for
numerous reasons has been deemed a red herring.
Unfortunately (?), the only solution is to keep the declaration and definition in the same header file.
If you want to make sure that the linker has a single instance of a template somewhere, ( and not rely on client code usage patterns ), you can instantiate it using the
template keyword on its own, like so;
in some cpp files somwhere...
<br />
template MyTemplatedClass<SomeType>;<br />
this will generate all the code for MyTemplatedClas<sometype> in the cpp file for the linker to use. HOWEVER....this doesn't work for template member functions, only for the whole class, ( or perhaps for free functions. )
So...'tis a bit messy...
-=jarl=-
|
|
|
|
|
aaaarghhh....i hate this... the < typename T > bit keeps getting lost in the wash....
oh well, we now know what we're both trying to say.
-=jarl=-
|
|
|
|
|
Try this approach:
class CMyClass
{
public:
template<class T> void MyFunction(T& Parameter)
{
}
}; Although you can legally move the definition of MyFunction outside the body of CMyClass declaration, VC++ 6.0 crashes at it, so this is your only option (don't know about VC++ 7.0).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry, I've corrected the syntax... could you take other look at it?
|
|
|
|
|
Right,
this has worked well.
Thank you very much.
|
|
|
|
|
btw, just a word of warning:
the VC compiler(s), ( even .NET 2003 ), are experts at throwing up red-herring errors when they encounter problems with templates. The errors you get might have little or nothing to do with the real problem...
-=jarl=-
|
|
|
|
|
I did: this is from an example I found. Now in my old project it shows up as a decent sized panewl, but in this one is tiny! I dont recall what I did specially to make the panel wider before....I have the same code in that project but theres got to be something else I did ....but what? Helllpppp!
int CPaletteStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatusBar::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rect(0,0,0,0);
m_THBImageRainbow.Create("Rainbow", WS_CHILD, rect, this, IDC_THBIMAGERAINBOW);
return 0;
}
void CPaletteStatusBar::OnSize(UINT nType, int cx, int cy)
{
CStatusBar::OnSize(nType, cx, cy);
UINT inx;
CRect rect;
inx = CommandToIndex (ID_INDICATOR_RAINBOW);
GetItemRect(inx, &rect);
m_THBImageRainbow.MoveWindow(rect);
m_THBImageRainbow.ShowWindow(SW_SHOW);
}
Appreciate your help,
ns
|
|
|
|
|
I stepped in and inx is coming out to be some really large positive integer...
Appreciate your help,
ns
|
|
|
|
|
the panel associated with your ID ID_INDICATOR_RAINBOW need a string in a string table, and the panel will be sized to fit the string that you set in the resources.
at least that's what I did.
Max.
|
|
|
|
|
That was it-----I now recall doing that in my old project!
Appreciate your help,
ns
|
|
|
|
|
Hi trying to use Visual Studio 6.0 (sp5) but there seams to be some problem with my project. I have copied some source files and stuff from other projects in to this new one and now my class wizard don’t work as supposed any more.
Some of my classes do not show up in the class wizard but they are in the project, I can compile and edit the files. This also results (I think) in that the so helpful “inline help” in the code for those classes do not work when I edit them.
Anyone know of how the wizard store its information or if there is anny tool or other way to fix a
corrupt project like this?
regards Me...
|
|
|
|
|
Hello,
I don't know if there are better solutions (I'm novice)
You can try this:
1) Get a copy of your full project directory in a safe place.
2) Delete the *.clw file (where the class information is stored)
3) Try to access the class wizard (Ctrl + W)
4) regenerate class information from your project files (automatic process)
5) reorganize all your classes in the class wizard tree.
hope this helps...
|
|
|
|
|
I have found that Class Wizard often gets confused when I am modifying the code. Almost always, the way to fix it is to edit the header file for a class, change a character (any character) and change it back. Save the file and things start working again.
I can only presume that this forces some kind of parsing action on the files involved.
Good luck!
|
|
|
|
|
we have one editor(Text) which is executable. we want to write an application which captures the keyboard press events when user is typing into the editor.
we can get the editor window handle by FindWindow() win32 API.
But how to capture the keyboard Events when user is typing something into Editor??.
thanks in advance
adi narayana.
|
|
|
|
|
You'll either have to install a hook on the external window and intercept its WM_KEYDOWN, etc. messages or use functions like GetKeyState() and GetAsyncKeyState() to retreive the keyboard state (globally) in a loop.
Jeremy Falcon
Imputek
|
|
|
|
|
BTW, if you are trying to make a password snatcher I'll kill you!
Jeremy Falcon
Imputek
|
|
|
|
|
Hi,
I am trying to find a way of executing remote commands on an FTP server programmatically (i.e. some way of getting the same functionality as the ftp command 'quote'). CFtpConnection and the related classes don't have this functionality, so does anyone have any idea where I should look? are there some SDK commands I can use?
Thanks in advance,
Alex
|
|
|
|
|
MFC: CFtpConnection::Command
SDK: ::FtpCommand
|
|
|
|