|
Hello!
I have two classes A and B, which is derived of A
class A {};<br />
<br />
template<class T> class B : protected A<br />
{<br />
public:<br />
operator const A&() { return *this; }<br />
};
When I try
A a;<br />
B<int> b;<br />
a = b;
I get the Error
error C2243: 'type cast' : Konvertierung von 'class B<int> *' zu 'const class A &' existiert bereits, aber es ist kein Zugriff darauf moeglich
Why? I have defined an public conversion operator...
Alex
|
|
|
|
|
You defined a const conversion operator, but your assignment is to a non-const l-value.
Software Zen: delete this;
|
|
|
|
|
LionAM wrote: public:
operator const A&() { return *this; }
create two operators, one const, one not :
template<class T> class B : protected A {
public:
operator const A&() const { return *this; }
operator A&() { return *this; }
};
|
|
|
|
|
Thank you for your answers!
Unfortunately this seems not to work
under Visual C++ 6 (another bug?) - but it
does work in VC2005 Express...
But if I declare the classes as friends,
it works (and I even don't need the public
type cast operator).
Alex
|
|
|
|
|
Hi!
i want send BN_CLICKED message to my static control, when a key is down, in its focus (in OnKeyDown event of my static control).
void CMyStatic::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) <br />
{<br />
this->SendMessage(BN_CLICKED ,<br />
MAKELONG(this->m_hWnd,BN_CLICKED),<br />
(LPARAM)(this->m_hWnd) );<br />
<br />
<br />
CStatic::OnKeyDown(nChar, nRepCnt, nFlags);<br />
}
but it don't work. what do i do?
Zo.Naderi-Iran
|
|
|
|
|
First of all, BN_CLICKED is not a message. It's a notification send as part of the message. PLease refer to the button messages..!
|
|
|
|
|
First of all, BN_CLICKED is a notification sent by a button to its parent window. The corresponding notification for a static window is STN_CLICKED .
That said, the simplest thing for you to do is this:
void CMyStatic::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
GetParent()->SendMessage(WM_COMMAND,
MAKEWPARAM(STN_CLICKED,GetDlgCtrlID()),
(LPARAM)m_hWnd);
CStatic::OnKeyDown(nChar, nRepCnt, nFlags);
} Note that this will cause your CMyStatic control to treat each keypress as a click.
Software Zen: delete this;
|
|
|
|
|
Thank you!
but it don't work.
void CMyStatic::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { <br />
this->SendMessage(WM_LBUTTONDOWN);<br />
this->SendMessage(WM_LBUTTONUP);<br />
CStatic::OnKeyDown(nChar, nRepCnt, nFlags);}<br />
this code runs Clicked work.
Zo.Naderi-Iran
|
|
|
|
|
You should be sending BM_CLICK instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
i want alarm beep application.So i searchde in nte i got some thing.I used MessageBeep() function.But it gives only sound of same frequency.But i need different sounds or speed for different things.For ex: if alrm value is low it gives very slow beep and if it si very high then it beeps very high speed.
I saw PlaySound() api and there we can give .wav file oi our resource file and we use it through SND_RESORCE flag.
I dont how to include .wav file in our resource(.rc) file.Pls help me out and give any ideas for this???
Anu
|
|
|
|
|
|
Beep(DWORD dwFreq,DWORD dwDuration) the more frequency you give, the more *creeech* it gives. For high alerts, give more duration. 1000(ms) gives you 1 sec of beep.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
I have come across what seems to be a complicated problem. I need to add
string resources and bitmap resources to an exe file after it is
compiled. Anyone have any ideas ???, any WIN API functions that can do this ???.
Many thanks.
|
|
|
|
|
Sure you can - ever use VC++ 6.0/5.0 (or earlier) to open an executable as resources? The APIs have been available since before Windows 3.1.
See functions like BeginUpdateResource(...) , UpdateResource(...) and EndUpdateResource(...) for more info.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks for the correction and sorry for the bad advice.
John
|
|
|
|
|
This is simple to do - this has been possible since before the 3.1 days ...
An easy example of this is to use VC++ 6.0 to open an executable (EXE or DLL) file and change the "Open As" type to Resources - you can then view, add, edit and even delete the resources of the application, save the changes back to the executable and then run the application again.
This is the #1 reason why you should never rely on the resources to enforce the behavior of your application (for example, if an edit control should be read-only or disabled, then make sure it is read-only/disabled by setting its style explicitly at runtime). This is something that nails naive developers when they want to do something like release a limited version of their app, but the limits are enforced strictly via the resources. This can also be a good thing - it allows well-written apps that keep all strings in their resources to be localized without access to the source code.
Using the APIs to do this is a bit tricky (and note that the APIs were not originally available on Win95, but only on WinNT) - it is easier to use something like VC++ 6.0 to do it.
Do you really need to know the APIs, or can you just use VC++ 6.0 to make the necessary changes?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks for the good advice,
I need to know the API's to be able to modify exe resources programmatically,
using visual c++ manually does not solve my problem.
A simple example of the stuff I need to do:
The program I am writing "Program B" needs to take user input, for example:
"This is my String" is entered into an Edit ctrl.
A string resource with a value of "This is my String" then needs to be created
in "Program A"(ProgA.exe). So when "Program A"(ProgA.exe) is executed it is able to display "This is my String" in a msg box/window etc...
I will look into the API's you have told me about, I think they will be a great help.
Once again, Many thanks.
|
|
|
|
|
|
how to set width and height of button in VC++?
|
|
|
|
|
|
|
It is spam and you are advertising a product you will charge for without asking permission let alone paying.
The vote level will show you what has happened.
|
|
|
|
|
Visual C++ 6 or Embedded Visual C++ support the notion of a source browser, should it be enabled. It's quite useful and allows rapid navigation across the project for a variety of things. Does anyone know if there is a command line interface for it?
I would like to be able to ask the browser (or any other tool for that matter): please list for me all of my classes and their member functions. Please sort by class name, public then private methods.
Any one have any suggestions? I could do this years ago on a mini. True, I didn't have visual editting, but the command line / text output was valuable for custom processing....
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
Bonjours
I wish to add a add in in exel XP 2002 with Windows SP2.
For that I have three file has to install:
1 fichier.lgc has to install in \ Windows \ applog
First problem I do not find this repertory hidden under same XP SP2 with the good options to select in Windows to explore. Thus I have to arrange this file in \ Windows \ appPatch and in \ Windows \ Prefetch in the place and the problem comes from I think.
1 fichier.xll has to install in \ office \ xlstart
1 fichier.ppp has instaler in \ office \ xlstart
And when the double click on the fichier.xll for the throw the error message is as follows “WinRT Driver not installed”.
Thus my questions are is this normal that I do not find the file \ Windows \ applog under win XP SP2 and how to install WinRT driver. Or then where to arrange my fichier.xll which must normally be in the repertory \ Windows \ applog
Thank you has all in advance for your assistance.
|
|
|
|
|
anyone can teach me and explain this code below cleary:
<br />
void sort_arr(const char *p_array[]){<br />
int comp_val, low_index, hi_index;<br />
const char *tmp;<br />
<br />
for(low_index = 0;p_array[low_index] != 0 &&p_array[low_index+1] != 0;low_index++){<br />
<br />
for(hi_index = low_index+1;p_array[hi_index] != 0;hi_index++){
<br />
comp_val=strcmp(p_array[hi_index],p_array[low_index]);<br />
if(comp_val >= 0)
continue;<br />
<br />
tmp = p_array[hi_index];<br />
p_array[hi_index] = p_array[low_index];<br />
p_array[low_index] = tmp;<br />
}<br />
}<br />
}
~~~@@@###EZRA###@@@~~~
|
|
|
|