|
i think because Create return result immediately after displaying dialog box.
so if you wrote CMydialog dlg; because you create in stack when get out of scope
dialog displayed for mere millisecond and then disapear!!!!!!!because desctructor is call!!!!
but you create in heap ! in heap i think some error such that occur! when you create in heap in some function when get out of scope cause that you lost address!!!!!!!!!(is that right?????)
so if you one that you dialog show in screen add these code:
after
dlg->ShowWindow(1);
add:
while(1);
i think you can see your dialog!!!!!!!!!!!
but the solution for this!
it is better that you create youu CMydialog instance some where else such as
constructor of your class such as *Dlg class..... .
it is not necessary to create in heap!
|
|
|
|
|
Check your return values. Create() is failing.
|
|
|
|
|
HANDLE h;
CEOID oidCallLog = (CEOID) pItemArray->rgRefs[0].pRef;
hr =PhoneOpenCallLog(&h);
CHR(hr);
CEOID re;
hr=PhoneSeekCallLog(h,CALLLOGSEEK_END,0,&re); //finding the ref of last record
CHR(hr);
DWORD i,pp;
CALLLOGENTRY pCall[150]; //limited to 150 entries
for (i=0;i<re;i++){
hr=PhoneSeekCallLog(h, CALLLOGSEEK_BEGINNING,i,&pp);
CHR(hr);
pCall[i].cbSize=sizeof(CALLLOGENTRY);
hr=PhoneGetCallLogEntry(h,&pCall[i]);
CHR(hr);
}
//testing now
__int32 temp;
oidCallLog=(CEOID)pCall[0]; //here i'm testing
temp=oidCallLog;
wchar_t buffer[64];
_itow(temp,buffer,10);
::MessageBox(GetActiveWindow(),buffer,TEXT("test"),MB_OK);
////////////// The result is really different when i check the value of oidCallLog ?????????????!!?!?!?!
-----------------------------------------------------------------
hi all,
i'm trying to add a new menu extension for call history.
i used everything based on Inbox menu extension sample in WM2005 sdk
evertything works great,except i dont know how to relate the Object id (oidCallLog) which i'm getting from the context menu,with the actualy call log entry.
i mean,pCall[i] has the call log. how to extract an object id from it which would be really same as the one i'm getting from pItemArray, so i know exactly this is the call log i'm selecting with context menu.
i hope i made it clear enough
Thankx alot in advance
|
|
|
|
|
hi every VC programmer, i have a math problem with my coding.
here is the sample:
#define NDIG 32 /* assume max no. of digits */
int getnum(void);
main(){
int val, i, count;
char chars[NDIG];
i = getnum();
/* print in binary */
val = i;
count = 0;
do{
//val = val / 2;
chars[count] = val % 2;
val = val / 2;
count = count + 1;
}while(val);
count = count - 1; ******(I wonder what this means?)*****
while(count >= 0){
printf("%d", chars[count]);
count = count - 1;
}
printf("\n")
}
getnum(){
int c, value;;
value = 0;
c = getchar();
while(c != '\n'){
value = 10*value + c - '0';
c = getchar();
}
return (value);
}
i hope you will reply this. Thanks
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
can u be more specific?
count=count - 1
means whatever was in count decrement it by 1
same as count--
is that ur question?
|
|
|
|
|
oops sorry ok it is my mistake.
my question is why count = count - 1 need to be added to the sample example.
if so, can you explain how to convert string to binary step by step in this coding.
Thanks
i am trying to figure out this puzzled code line.
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
The -1 is because it was incremented just prior to bailing out of the loop so that puts it back to where it should be.
For generating binary strings I usually use a bitmasking scheme. Something like this :
void GenBinaryString( BYTE byte, CString &str )
{
str = _T( "" );
const int bytebits = 8;
BYTE mask = 1 << ( bytebits - 1 );
for( int x = 0; x < bytebits; x++, mask >>= 1 )
{
str += ( mask & byte ) ? _T( "1" ) : _T( "0" );
if( x == 3 )
str += _T( " " );
}
}
|
|
|
|
|
Thanks
but your coding look more complicating to me.. T_T
Can you explain this clearly with comments per line? If cannot,
never mind, i will slowly learning.
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
Shouldn't the compiler call the method in the base class when the method with the same name is not declared as virtual?
Is this specific to VS2003?
#include <iostream>
using namespace std;
class mammal
{
public:
void walk () {cout << "mammal walks" << endl;}
protected:
mammal (bool pFacialhair) {facialhair = pFacialhair;};
bool facialhair;
virtual void takesaleak () {cout << "mammal takes a leak" << endl;}
};
class dog : public mammal
{
private:
bool takingapiss;
public:
dog() : mammal(true)
{
facialhair = true;
};
int legs;
void walk () {cout << "dog walks" << endl;}
void takesaleak () {cout << "dog takes a leak" << endl;}
};
void main ()
{ dog Fido;
Fido.walk(); //Error: mammal walks Actually the output is: dog walks
Fido.takesaleak(); //dog takes a leak
//Fido.takingapiss; // not allowed because it is a protected method
}
Error!
Jon
|
|
|
|
|
jon_80 wrote: Shouldn't the compiler call the method in the base class when the method with the same name is not declared as virtual?
No.
Whether mammal's walk() is virtual or not, dog's walk() (if defined) will be called first, becuase fido object is constructed from dog class. And, mammal's walk() will not be called automatically. Virtual or not just controls whether this method can be overridden by the derived class. There is no confusing polymophism stuff here. If you want mammal's walk() to get called, either
1) you have to place it inside dog's walk(), or
2) if mammal's walk() is virtual, cast fido object using a mammal pointer and call walk().
Virtual destructor is an exception, which I assume you already know.
Best,
Jun
|
|
|
|
|
Fido.walk();
you call Walk of Fido object .do u expect calling Walk of mammal?
if you wanna see virtual ! try these ,so you can see virtual how work!
first add this function just in mammal !
void ShowWalk(){ Walk()};
in main you try this code:
dog Fido;
mammal F;
Fido.ShowWalk();
F.ShowWalk();
so you can see polymorphism!
first output is : dog walks
second output is : mammal walks
is that your quastion?
|
|
|
|
|
Um, that is not polymorphism.
|
|
|
|
|
Polymorphism (and virtual ) only have an effect when making function calls through pointers.
When you write Fido.walk() what do you expect to happen? dog has a walk() method, so that's what gets called.
|
|
|
|
|
Michael Dunn wrote: Polymorphism (and virtual) only have an effect when making function calls through pointers.
valid for references,too.
|
|
|
|
|
Hi friends,
My application consists of an interaction b/w the GUI and a RS-232 serial
port communication with a embedded device.
Initially we had a GUI menu based, where depending upon the user click
on the GUI , we used to send and receive the messages from the device.
Now, we have a requirement where we need to have a single start-up
dialog box instead of a menu for each selection.These means now we have
to show all the data from the device initially to the user.
For example say , when the user clicks View->ConfigDialog menu option
i have to pop-up a dialog box showing all the data from the device
Could you please help me regarding this.
Regards,
Veeresh
|
|
|
|
|
int filenumber;
CString Pathname[20],Filename[20];
CFileDialog fd (TRUE,NULL,NULL,
OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT
,"DCL FILE|*.DCL||");
if (fd.DoModal()==IDOK)
{
POSITION pos;
pos = fd.GetStartPosition();
filenumber = 0;
while (pos!=NULL)
{
Pathname[filenumber] = fd.GetNextPathName(pos);
TRACE("Pathname[%d]=%s\n",filenumber,
Pathname[filenumber]);
filenumber++;
}
When Open file more than 8 file together it will generate error.
Anybody know how to solve this problem?
|
|
|
|
|
|
See
<br />
int filenumber = 0;<br />
POSITION pos;<br />
CString Pathname[20];<br />
char* lptstr = new char[256];<br />
<br />
CFileDialog m_FileDialog(1,0,0,OFN_ALLOWMULTISELECT | OFN_EXPLORER);<br />
<br />
m_FileDialog.m_ofn.nMaxFile = 256;<br />
m_FileDialog.m_ofn.lpstrFile = lptstr;<br />
m_FileDialog.m_ofn.lpstrFile[0] = NULL;<br />
<br />
m_FileDialog.DoModal();<br />
<br />
<br />
pos = m_FileDialog.GetStartPosition();<br />
while (pos!=NULL)<br />
{<br />
Pathname[filenumber] = m_FileDialog.GetNextPathName(pos);<br />
TRACE("Pathname[%d]=%s\n",filenumber,Pathname[filenumber]);<br />
filenumber++;<br />
}<br />
|
|
|
|
|
Is there a way to know the color in which slider ticks should be painted by system?
Thanks.
|
|
|
|
|
Does this[^]helps you ? Using option COLOR_SCROLLBAR .
|
|
|
|
|
No, I've already checked all possible arguments to GetSysColor, no one match the color with which ticks painted... I expect this may be related to themes, because I work in WinXP, but how to be in this case?
|
|
|
|
|
Hello everyone,
I am going to design a Cache in C/C++ (memory cache). I have two different approaches to design/implement it, any comments will be appreciated.
Design 1, using a map (hashtable) to store key --> object pointer relationship (simple and straight forward);
Design 2, store real object or object pointer in a stack/linked list/queue/array as an internal storage data structure, then using a map (hashtable) as an external interface to mapping key --> index in the stack/linked list/queue/array; (in this design, when accessing an object, we need two times mapping, first mapping key to index in the stack/linked list/queue/array, then using the index to access the real object)
I am wondering any advantages or disadvantages of the two designs. Any better design approach suggestion will be appreciated.
thanks in advance,
George
|
|
|
|
|
I would like to know how to inherit from classes and set protected properties of the base class within the derived class:
class mammal
{
protected:
mammal (bool pFacialhair) {facialhair = pFacialhair;};
bool facialhair;
};
class dog : public mammal
{
private:
bool takingapiss;
public:
dog()
{
facialhair = true;
};
int legs;
};
Error:
error C2512: 'mammal' : no appropriate default constructor available
Jon
|
|
|
|
|
you dog class should be like this:
class dog : public mammal
{
private:
bool takinggapiss;
public:
dog(bool pFacialhair):mammal(pFacialhair)
{
....
}
...
}
when class dog inherits class mammal, the construction of an object of class mammal must be finished before the construction of the object of class dog. because you don't have a default constructor for class mammal, you have to provide an argument for the construction of mammal in the constructor of class dog.
I don't know if I have made myself clear.
-- modified at 7:08 Saturday 9th September, 2006
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|
|
ewighell wrote: your dog class should be like this:
dog::dog(bool pFacialhair)
: mammal(pFacialhair) {
//...
}
or like this...
dog::dog()
: mammal(true) {
}
|
|
|
|