|
PatrykDabrowski wrote: CListerDialog m_lister(CDialog::FromHandle(GetDesktopWindow()));
m_pMainWnd=(CWnd *)&m_lister;
m_lister.DoModal();
Hu....Wy are you doing that....
Anyway, I think you have to use ::GetDesktopWindow() insted of GetDesktopWindow() .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
"that" - You mean, setting parent window to Desktop?? I set it to have "full thread separated" dialogs. When I pass NULL to the constructor then my 'child' window minimize when I minimize my main dialog window. When I set Desktop window as its parent, I can minimize both windows independently (plus, my 'child' window has its own entry in taskbar;)
Isn't that right?
|
|
|
|
|
PatrykDabrowski wrote: How to setup window's position before it is shown?
You could override PreCreateWindow().
In the override, call the base class PreCreateWindow() then change the x,y,cx,cy members of the
passed CREATESTRUCT.
Or not for a dialog
Mark
-- modified at 13:51 Sunday 14th January, 2007
|
|
|
|
|
MFC determines whether it should auto-center a dialog by comparing its RECT before and after your OnInitDialog() runs. (See _AfxPreInitDialog() and _AfxPostInitDialog() .) If the RECT is the same before and after, then MFC centers it. If the dialog's default position is (0,0) then your SetWindowPos() call won't move it, and it will be centered.
You can either use another position, or call ShowWindow(SW_SHOW) in OnInitDialog() so _AfxPostInitDialog() won't do its auto-centering logic.
|
|
|
|
|
WOW, thanks Nice trick with this (0,0) window position;) Now it works fine. Thanks again
|
|
|
|
|
Use MoveWindow in OnInitDialog() .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi all
The following code snippet....
ifstream f_;
f_.open(fname);
while(i < records_in_file) {
f_ >> data_[i].idx_ >> ws;
f_ >> data_[i].noOfRegs_ >> ws;
i++;
}
.. is reading the following file
0001 13
0002 24
0003 209
0004 85
0005 3
0006 122
0007 28
0008 9
0009 31
0010 27
… and so on …
All seems to work for the first 7 records, but when it comes to read the 8th record (i.e. “0008 9”), the first value it reads is 0 (zero) and then it reads the 8.
I can’t figure out what is going wrong. Any ideas? Is it something to do with ASCII screwing up the input stream.
As an aside I have also tried a “getline” solution, but run into similar problems.
Cheers
Graham
|
|
|
|
|
Any 'O' char (ASCII code 79) between zeroes?
Cheers
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
No, I have copied/pasted from the above records (as they are zeroes) and also manually put in zeroes, but same result.
There are definitely 3 zeroes before the 8.
Cheers
Graham
|
|
|
|
|
Can you please provide a code snippet showing the declaration of the variables?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Sure
In a header file
struct data {
int idx_;
int noOfRegs_;
} *data_;
.. and then later (in a function) ...
int records_in_file = 152;
CString fname = "..//Data//sta-f-83.crs";
data_ = new data[records_in_file];
// and this is what I posted earlier
ifstream f_;
f_.open(fname);
while(i < records_in_file) {
f_ >> data_[i].idx_ >> ws;
f_ >> data_[i].noOfRegs_ >> ws;
i++;
}
Thx
Graham
|
|
|
|
|
As a wild guess I'd say it's interpreting the numbers as octal due to the leading 0. 8 is not a legal octal digit so the stream stops reading after "000" which is why you get 0.
|
|
|
|
|
Thanks
So what do I do?
Graham
|
|
|
|
|
I don't know the stream classes well enough, I would guess that there is a function or manipulator that will make it parse numbers as base 10.
|
|
|
|
|
Use f_.setf(ios::dec) just befor reading values. For istance:
f_.setf(ios::dec);
while(i < records_in_file) {
f_ >> data_[i].idx_ >> ws;
f_ >> data_[i].noOfRegs_ >> ws;
i++;
}
I have to admit, Michael Dunn was very clever.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Just quickly tried it - need to fully test - but looks good.
Thanks both. I owe you one.
Cheers
Graham
|
|
|
|
|
I'm working on my psychic debugging powers.
|
|
|
|
|
Michael Dunn wrote: I'm working on my psychic debugging powers
Hey Mike, I have a bug. How can I fix it?
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
|
|
|
Hi all,
my question is if I define a class myClass with destructor, assign operator (=) and copy constructor, etc etc.
If I later use my class like this:
myClass &a=*new myClass(whatever);
myClass &b=a;
Do I have to explicitly delete b? I've read you should only delete a class if you have instantiated it with a new. I know that behind the curtains b is created with a new call inside the dll, but do I have to delete it explicitly from my app?
thanks
|
|
|
|
|
gumi_r@msn.com wrote: myClass &a=*new myClass(whatever);
myClass &b=a;
since you've dynamically allocated memory for an istance of myClass , then you have to delete it somewhere. You can call either delete &b or delete &a (of course don't call both).
Cheers
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Ok thanks. That makes sense as I'm already deleting any pointers I need to inside my copy constructor.
Next step would be the assignment operator. Say for example y have:
myClass &a=*new myClass(whatever);
myClass &b=*new myClass(whatever);
myClass &c=a+b;
do I have to delete &c?
thanks for any replies.
|
|
|
|
|
gumi_r@msn.com wrote: myClass &c=a+b;
IMHO you should not do this, because you're trying to assign a reference to a temporary object. For instance, the following is noy allowed(the compiler complains about):
int &i= *new int(5);
int &j=i;
int &k=i+j;
BTW: Doing some experimentation?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|