|
Raffi wrote:
feel really stupid now, but thanks a lot
We all feel that way at times
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Hi!
I'm new at MFC and dialog programming. I was just wondering if there is any kind of main loop function in a dialog?
Thanks for your answers
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/dlgboxes_5lib.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_atl_CDialogImpl.3a3a.DialogProc.asp
-Gile
|
|
|
|
|
MFC hides the message loop from us. That's supposedly the way OOP works. But if you really want to intercept and handle messages, you can do that without too much effort
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
A regular modal dialog created with the Win32 functions contains an internal message pump. However, the MFC version of a modal dialog is still created with CreateDialog. This will allow MFC to control the message loop itself and adds the ability to have the pretranslate message handlers for the dialog.
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!
|
|
|
|
|
I have created CTypedPtrArray'<CPtrArray,FileInfo*>' fileArray; //ignore ' coz i don't have it on my application. ' is only for < to show on this site.
FileInfo is a class name:
<br />
class FileInfo <br />
{<br />
public : <br />
int status;<br />
CString path;<br />
CString name;<br />
CString size;<br />
CString createdTime;<br />
CString lastWrite;<br />
CString lastAccess;<br />
CString type;<br />
};<br />
the problem is when i calling CreateFileArray() from method 1 . no problem at all. but when i call from method 2. there is a run time error. I'm calling the same way. but only calling once at the time. not calling from both of method 1 and 2.
<br />
<br />
void CSMPprojectDlg::CreateFileArray()<br />
{<br />
HTREEITEM hItem = m_TreeCtrl.GetRootItem();<br />
CreateEmptyFileArray();
CreateFileArray(hItem);<br />
}<br />
void CSMPprojectDlg::CreateEmptyFileArray()<br />
{<br />
int size = fileArray.GetSize();<br />
if(size != 0)<br />
{<br />
AfxMessageBox("hi");<br />
for (int i =0;i<size;i++)<br />
{ <br />
FileInfo* fileinfo =fileArray.GetAt(i);<br />
delete fileinfo;<br />
<br />
<br />
}<br />
}<br />
}<br />
<br />
void CSMPprojectDlg::CreateFileArray( HTREEITEM hItem)<br />
{<br />
<br />
while(hItem != NULL)<br />
{<br />
{<br />
<br />
FileInfo *fileinfo= new FileInfo();<br />
fileinfo = (FileInfo*)m_TreeCtrl.GetItemData(hItem); <br />
MessageBox(fileinfo->name);<br />
if(m_TreeCtrl.ItemHasChildren(hItem) )<br />
CreateFileArray(m_TreeCtrl.GetChildItem(hItem));<br />
if(fileinfo->status == FILE)<br />
{<br />
MessageBox(fileinfo->name);<br />
fileArray.Add(fileinfo);<br />
}<br />
}<br />
hItem = m_TreeCtrl.GetNextSiblingItem(hItem);<br />
}<br />
}
why can't i call from method 2?????
<br />
<br />
void CSMPprojectDlg::PrintChecked()<br />
{<br />
UpdateData(TRUE);<br />
<br />
HTREEITEM hItem;<br />
hItem=m_TreeCtrl.GetRootItem();<br />
<br />
if(!(IsAnyItemChecked(hItem,hItem)))<br />
MessageBox("No file is checked!!"); <br />
else<br />
{<br />
printedfileName.Empty();<br />
int respond;<br />
respond= GetLocationAndName(printedfileName);
<br />
if (!respond)<br />
{<br />
printedfileName = "j:\\BlowBackQC\\"+Company+"_"+Job+"_"+CD+"_PrintedFileList.txt";<br />
CString message = "The location and name of the file: \n\t"+printedfileName;<br />
MessageBox(message);<br />
<br />
}<br />
<br />
QC_file.open(printedfileName);
<br />
QC_file<<"\t\t\t Company Name: "<<Company<<"\n\t\t\t CD Number: "<<CD<<"\n\t\t\t Job Number: "<<Job<br />
<<"\n\t\t\t Total File: "<<File_counter<<"\n\t\t\t Total Folder: "<<Folder_counter<<endl<<setw(80)<<setfill('=')<<endl<br />
<<setfill(' ')<<endl;<br />
<br />
if(m_SortingWay == 1)<br />
QC_file<<" Date \t\t Size\t\tEsti_page_print\t\t Ext\t\t FileName\n"<<setw(80)<<setfill('=')<<endl<<setfill(' ')<<endl;<br />
else<br />
QC_file<<" Date \t\t Size\t\tEsti_page_print\t\t FileName\n"<<setw(80)<<setfill('=')<<endl<<setfill(' ')<<endl;<br />
<br />
CreateFileArray();<br />
int size = fileArray.GetSize();<br />
if(size !=0)<br />
{<br />
for(int i=0;i<size;i++)<br />
{<br />
FileInfo *fileinfo = new FileInfo();<br />
fileinfo = fileArray.GetAt(i);<br />
CString a = fileinfo->name +"\n"+ fileinfo->size;<br />
MessageBox(a);<br />
<br />
}<br />
}<br />
QC_file.close(); <br />
<br />
<br />
<br />
}<br />
printingThread =0;<br />
}<br />
}
|
|
|
|
|
I can't help much because I am not afflicted with crappy Microsoft containers, I use the STL.
However -
Win wrote:
//ignore ' coz i don't have it on my application. ' is only for < to show on this site.
You can use ampersand ( shift 7 ) and lt or gt to get the < > symbols, or check the box below that says to display the message as-is.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Okay, read this. "Enter a 5x6 matrix. Print the original matrix and then print the transpose of the matrix, and the reverse of the matrix." I was handed that and I have no idea what to do. If anyone could send post some sample code to give me an idea of what to do, I'd greatly apprciate it. Thanks. This stupid thing is due tomorrow. Send mail to nywebhead@hotmail.com if you can help. Thanks again,
Mik
|
|
|
|
|
A matrix is the same as a two dimensional array. Do you know what that is ? Your teacher obviously thinks you should.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Two Dimensional array....hmmmmm.....never heard of it, but I'll look it up. Thanks Christian.
|
|
|
|
|
Ok, when I enter the below code, it says, subscript requires array or pointer type. What does that mean?
#include<iostream.h>
int r,c,x;
int a[100][100];
int b[100][100];
main(){
a[0][0] = 10;
a[0][1] = 11;
a[1][0] = 15;
a[1][1] = 21;
b[0][0] = 10;
b[0][1] = 11;
b[1][0] = 15;
b[1][1] = 21;
for (r=0; r<=4; ++r){
for (c=0; c<=5; ++c){
cout<
|
|
|
|
|
nywebhead wrote:
cout<<x[r][c]<<" ";<="" i="">
x is an integer.
Use a or b which you have declared as 2-d arrays
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Thanks, I figured it out. Geez, this is tedious.
|
|
|
|
|
nywebhead wrote:
Geez, this is tedious.
LOL
Don't worry. It'll get easier as you progress
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Changing the colors of buttons, and edit boxes is easy with Visual Basic, but I've grown up and am now using Visual C++. The problem I have now is that I have no clue on how to change the color of buttons and edit boxes.
Please, Gurus and Masters of C++, please almighty gods, tell me how I can do this. I will worship at your feet if I get a response. I am repentant of my VB ways and am now bowing before you.
|
|
|
|
|
You would either add a handler for OnCtlColor or make the button Owner Draw.
Also look at:
http://www.codeproject.com/staticctrl/coloredit_colorstatic.asp
http://www.codeproject.com/staticctrl/clabel.asp
Instead of using an Anonymous post you might like to Register here at CP which makes us CP regulars happier.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Instead of using an Anonymous post you might like to Register here at CP which makes us CP regulars happier.
The bad thing about anonymous posts is that you dont get mail notifications
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I wish to capture keystrokes much like hot keys.
Instead of setting up buttons with captions like
&0Zero, &1One, ... &9Nine.
I would like to be able to capture keystrokes like
ALT 0, ... ALT 9.
I guess the PreTranslate() is the right place to do this.
My question is how do I tell that both the ALT key is down when the 0 key was pressed?
Please point me in the right direction.
Thanks
|
|
|
|
|
|
Michael Dunn wrote:
If your app is SDI or MDI, just create accelerators for those keystrokes.
Adding to what Mike said. If it a dialog based APP, you can read this article which shows how to have accelerator keys working in a dialog based app :-
http://www.codeproject.com/useritems/pretransdialog01.asp
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
For the life of me I can't remember how to do this... I am creating my own file format for a hobby application I'm working on and I am trying to remember how to store a 'C' constant string in an integer variable.
I have a dummy header for now defined as:
<br />
struct Header {<br />
int Identity;
int Version;
};<br />
I then proceed to store info but when I try to store SAM1 it doesn't seem to store everything. I'm just a little confused and don't remember how to do this, any help would be greatly appreciated. Or, any other method you suggest to store a string in the header file would be appreciated as well.
Thanks in advance.
Sam
----
"No special sig just plain old Sam..."
|
|
|
|
|
If the storage of id is limited in 4 letters, this way would do:
struct Header {
int Identity;
int Version;
};
Header hh;
memcpy(&hh.Identity, "SAM1", 4);
But I don't think int a good choice for the case...
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Thanks for the heads up I would of never guessed that even after seeing the answer I don't remember that What would you suggest be the best use?
Thanks.
Sam
----
"No special sig just plain old Sam..."
|
|
|
|
|
From all the other source, mostly the source for the MD2 file format stores this type of information int an 'integer' variable.
Originally I would suggest you to use char array, but after having seen your answer to Michael, I couldn't imagine any other methods.
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
I don't get it. Why would you want to store a string in an integer? You could only store a pointer to character array, which would be meaningless when read back in?
What's wrong with a good old char[4]?
Michael
Communication is the first step towards enlightenment.
|
|
|
|