|
Hit <Ctrl + Alt>+<Print Screen> to copy an image of the dialog that currently has focus to the clipboard. You can then paste it into your Paint and save it.
Mike
|
|
|
|
|
Alt+Print Screen is sufficient (the Ctrl key is not required).
Software Zen: delete this;
|
|
|
|
|
Alt+PrntScrn will copy the active window to the clipboard. You can then paste to your documentation software.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have a dialog based app that uses multiple modeless dialogs to overlay portions of the main dialog. I have an array of structs defined in the public portion of the main dialog like this:
public:
MYSTRUCT MainList[MAX_LIST];
The struct looks like this:
typedef struct MyStruct
{
char Index[6];
CString Title;
CString Artist;
CString Album;
CString FileName;
CString Time;
CString Genre;
int TimesPlayed;
} MYSTRUCT, *LPMYSTRUCT;
When I access this list from one of the overlay dialog classes using a dialog pointer, it sometimes works ok, and sometimes doesn't see the data in the list, although the data is there.
If the overlay is created as a child, it works ok, but I lose my menu in the overlay, and parts of the main dialog show through the overlay. If it's created as a popup or overlapped, it gets flaky.
I tried creating the list as a static global, but that only made it not work consistantly in the overlays.
Any ideas as to why it works sometimes, and not others?
TIA,
Rick
|
|
|
|
|
Well I did something like that sometime back, and the way I made it work was as follows :
keep this structure in the public portion of the main dialog as well as the child dialogs.Then you have to detect when the modeless dialogs are changing , ie say dialog 1 is hiding and dialog 2 is showing.At that point of time you will have the fill the structure in the dialog1 class, and from the maindialog copy the values of the structure in dialog1 to the maindialog structure.
Hope this helps.
_KANE_
"Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?"
|
|
|
|
|
That I can do, but I can't figure out why it's not accessible through the other dialogs in it's global form.
I also tried creating a CList globally, and I populate it in one dialog class, yet it shows empty in another dialog class???
I put the CList in my main app header file, and all the dialog classes include that, seems to me they should all be accessing the same data?
|
|
|
|
|
How can I display a Gif image against an item in a CTreeCtrl?
|
|
|
|
|
Render the gif to a memory DC with a bitmap selected into it, then use that bitmap to add to an image list.
You can use GDI+ or the IPicture interface to do this.
Steve S
Developer for hire
|
|
|
|
|
Hi everyone,
I've some problems including header files.
I have 2 classes COne and CTwo, and COne implements CTwo objects, so I put an include CTwo statement in COne.h.
Both classes must use some functions declared in a Myheader.h file.
Including Myheader in both .cpp or .h files produces linking error, and the same does including Myheader.h in CTwo.h to exploit the inheritance of the include statement.
The error is LNK1169: one or more multiply defined symbol founds.
Any suggestion?
|
|
|
|
|
Did you put these statements in all of your *.h files :
#if !defined YOURFILENAME<br />
#define YOURFILENAME<br />
<br />
...<br />
...<br />
...<br />
<br />
#endif
Replace YOURFILENAME by something unique to every file.
|
|
|
|
|
Those statements are set by default by Visual Studio in every class file. I tried also to create a dll file from Myheader, but even if i add that library to my project, the app doesn't recognize the functions of the library. Should I addd a .DEF file?
|
|
|
|
|
Hello
You should not include Myheader.h in both the files. You can include the Myheader.h in CTwo.h and include CTwo.h in COne.h
I hope it would work...
Bye,
Sreekanth Muralidharan
|
|
|
|
|
I've already tried this way, but the result was the same.
I solved the problem in another way.
Thanks to everyone
|
|
|
|
|
Hello buddies,
I am designing a queue by a linked list for an application. I wrote the following code while it brought up an exception in the line marked here. Could you please help me out ?
#include <stdio.h><br />
#include <conio.h><br />
struct queuelist<br />
{<br />
int intData;<br />
int valid;<br />
struct queuelist* next;<br />
<br />
};<br />
struct queuelist *head, *tail;<br />
<br />
int AddToQueue(struct queuelist*,int);<br />
int RemoveFromQueue(struct queuelist*);<br />
int DeleteQueue(struct queuelist*);<br />
void DisplayQueue(struct queuelist*);<br />
void menu();<br />
void menu()<br />
{<br />
<br />
int option=0;<br />
struct queuelist* queue;<br />
int data;<br />
printf("Queue Manipulation Menu\n");<br />
printf("........................\n\n");<br />
printf("1. Add member to queue.\n");<br />
printf("2. Extract next member.\n");<br />
printf("3. Delete whole queue.\n");<br />
printf("4. Help\n");<br />
printf("5. Display queue contents.\n");<br />
printf("6. Quit.\n");<br />
scanf("%d",&option);<br />
switch(option)<br />
{<br />
case 1:<br />
printf("Adding to queue.\n");<br />
printf("Member: ");<br />
scanf("%d",&data);<br />
if(AddToQueue(queue,data)==-1)<br />
printf("Could not add..\n");<br />
else<br />
printf("Added..\n");<br />
menu();<br />
<br />
case 2:<br />
system("cls");<br />
printf("Extract next member.\n");<br />
RemoveFromQueue(queue);<br />
menu();<br />
<br />
<br />
case 3:<br />
DeleteQueue(queue);<br />
menu();<br />
<br />
case 4:<br />
printf("Under Construction.\n");<br />
menu();<br />
case 5:<br />
printf("Queue Contents.\n");<br />
DisplayQueue(queue);<br />
menu();<br />
case 6:<br />
exit(0);<br />
<br />
default:<br />
printf("Invalid Option..\n");<br />
<br />
}<br />
}<br />
<br />
void main()<br />
{<br />
system("cls");<br />
menu();<br />
getch();<br />
<br />
}<br />
<br />
int AddToQueue(struct queuelist** q, int data)<br />
{<br />
struct queuelist** temp;<br />
q = head;<br />
if(q == NULL)<br />
{<br />
printf("First member in queue.\n");<br />
temp = (struct queuelist**)malloc(sizeof(struct queuelist));<br />
if(*temp == NULL)<br />
{<br />
printf("Not enough memory. Stopping...\n");<br />
return -1;<br />
}<br />
else<br />
{<br />
(*temp)->intData = data;<br />
(*temp)->next=NULL;<br />
(*temp)->valid=1;<br />
<br />
(*q)->next = temp;<br />
head = *q;<br />
tail = *q;<br />
<br />
}<br />
<br />
<br />
}<br />
else<br />
{<br />
while((*q)->next!=NULL) (*q) = &(*q)->next;<br />
<br />
temp = (struct queuelist**)malloc(sizeof(struct queuelist));<br />
if((*temp) == NULL)<br />
{<br />
printf("Not enough memory. Quitting...\n");<br />
return -1;<br />
}<br />
else<br />
{<br />
(*temp)->intData = data;<br />
(*temp)->next=NULL;<br />
(*q)->next = *temp;<br />
(*q) = (*q)->next;<br />
(*q)->valid = 1;<br />
tail = *q;<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
<br />
}<br />
<br />
<br />
void DisplayQueue(struct queuelist* queue)<br />
{<br />
system("cls");<br />
queue = head;<br />
if(queue == NULL || queue->valid != 1)<br />
{<br />
printf("Empty Queue");<br />
}<br />
else<br />
{<br />
while(queue != NULL)<br />
{<br />
printf("||%d|%x||->",queue->intData,queue->next);<br />
queue = queue->next;<br />
}<br />
<br />
}<br />
printf("\n");<br />
<br />
}<br />
<br />
int RemoveFromQueue(struct queuelist* queue)<br />
{<br />
<br />
struct queuelist* prev;<br />
struct queuelist* second;<br />
queue = head;<br />
if(queue->valid !=1)<br />
{<br />
printf("Queue Exhausted. No members.\n");<br />
return -1;<br />
}<br />
else<br />
{<br />
queue = head;<br />
prev = queue;<br />
queue = queue->next;<br />
second = queue;<br />
head = queue;<br />
printf("Popped off : %d at %x\n",prev->intData, prev->next);<br />
prev->next = NULL;<br />
free(prev);<br />
}<br />
<br />
<br />
<br />
}<br />
int DeleteQueue(struct queuelist* queue)<br />
{<br />
struct queuelist* prev;<br />
queue = head;<br />
while(queue!=NULL)<br />
{<br />
prev = queue;<br />
queue = queue->next;<br />
queue->valid=0;<br />
free(prev);<br />
}<br />
<br />
<br />
}
Bye....
Sreekanth Muralidharan
|
|
|
|
|
Beside writing code for learning new things, I would never ever implement my own linked list or so when there are powerful, well-tested and broadly used collection classes like the STL [^].
--
Affordable Windows-based CMS: www.zeta-producer.de/enu
|
|
|
|
|
Hello friend,
I would not prefer using STL for my small application. If you would refer to the code and find out the bug, it would be of great help to me.
Regards,
Sreekanth Muralidharan
|
|
|
|
|
Firstly, I would offer the same advice, don't write your own linked lists or collections etc, use STL or the MFC CList etc.
The problem in your code appears to be a confusion in the pointers, and the code is littered with such problems, eg in AddToQueue(), you have set temp to be of type struct questlist ** , but your call to malloc (btw why are you not using new???), will create a pointer to a single queuelist (i.e. (struct queuelist *)). So you should change the code to something like
struct queuelist *temp = NULL;
.............
temp = (struct queuelist *)malloc( sizeof(struct queuelist) );
if ( temp == NULL )
{
// Not enough memory etc
}
else
{
temp->intData = data;
temp->next=NULL;
temp->valid=1;
*q = temp;
}
The function call to AddToQueue() in your main part should read AddToQueue( &queue ) else the wrong type is being passed to the function.
I must admit that I am surprised that your compiler did not generate warning messages with your code? I think that you would be best of revisiting all of your code, and checking all your pointers and paraeters. Remember that malloc will only return a pointer to a section of memory that you have allocated.
Better still, use STL or perhaps the MFC CList template.
|
|
|
|
|
Hello
Thanks to all who took their time to go through my bugful code.
Regards,
Sreekanth Muralidharan
|
|
|
|
|
1) This code is totaly written in C.
2) You are using uninitialised variables (ONE CAUSE OF EXCEPTION).
3) You are passing uneeded queue pointer arguments. Every function can see the global head variable and since you are only using one list you do not need to pass pointer arround.
4) You should be using a loop in the menu() function, instead of recursion, to get usere input.
5) You have variable that are not needed or actualy used.
6) You can use a temporary queue pointer in the function that need access to the queue.
I tried to point out as many problems as I could in your current code (without rewring it).
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
struct queuelist
{
int intData;
int valid;
struct queuelist* next;
};
struct queuelist *head, *tail;
int AddToQueue(struct queuelist*,int);
void menu()
{
int option=0;
struct queuelist* queue;
int data;
printf("Queue Manipulation Menu\n");
switch(option)
{
case 1:
if(AddToQueue(queue,data)==-1)
menu();
case 6:
exit(0);
default:
printf("Invalid Option..\n");
}
}
void main()
{ }
int AddToQueue(struct queuelist** q, int data)
{
struct queuelist** temp;
q = head;
if(q == NULL)
{ }
else
{ }
}
void DisplayQueue(struct queuelist* queue)
{
system("cls");
queue = head;
}
int RemoveFromQueue(struct queuelist* queue)
{
struct queuelist* prev;
struct queuelist* second;
queue = head;
if(queue->valid !=1)
{ }
else
{
queue = head;
prev = queue;
queue = queue->next;
second = queue;
head = queue;
printf("Popped off : %d at %x\n",prev->intData, prev->next);
prev->next = NULL;
free(prev);
}
}
int DeleteQueue(struct queuelist* queue)
{
struct queuelist* prev;
queue = head;
while(queue!=NULL)
{ }
}
Good luck and keep trying!
INTP
|
|
|
|
|
Hello,
I cleared the above problems with the following updates to my original code:
#include <stdio.h><br />
#include <conio.h><br />
#include <process.h><br />
#include <malloc.h><br />
<br />
struct queuelist<br />
{<br />
int intData;<br />
int valid;<br />
struct queuelist* next;<br />
<br />
};<br />
struct queuelist *head, *tail;<br />
<br />
int AddToQueue(struct queuelist*,int);<br />
int RemoveFromQueue(struct queuelist*);<br />
int DeleteQueue(struct queuelist*);<br />
void DisplayQueue(struct queuelist*);<br />
void menu();<br />
struct queuelist* queue=NULL;<br />
<br />
void menu()<br />
{<br />
<br />
int option=0;<br />
<br />
int data=0;<br />
printf("Queue Manipulation Menu\n");<br />
printf("........................\n\n");<br />
printf("1. Add member to queue.\n");<br />
printf("2. Extract next member.\n");<br />
printf("3. Delete whole queue.\n");<br />
printf("4. Help\n");<br />
printf("5. Display queue contents.\n");<br />
printf("6. Quit.\n");<br />
scanf("%d",&option);<br />
switch(option)<br />
{<br />
case 1:<br />
queue=head;<br />
printf("Adding to queue.\n");<br />
printf("Member: ");<br />
scanf("%d",&data);<br />
if(AddToQueue(queue,data)==-1)<br />
printf("Could not add..\n");<br />
else<br />
printf("Added..\n");<br />
break;<br />
<br />
case 2:<br />
system("cls");<br />
printf("Extract next member.\n");<br />
RemoveFromQueue(queue);<br />
break;<br />
<br />
case 3:<br />
DeleteQueue(queue);<br />
break;<br />
<br />
case 4:<br />
printf("Under Construction.\n");<br />
case 5:<br />
printf("Queue Contents.\n");<br />
DisplayQueue(queue);<br />
break;<br />
<br />
case 6:<br />
exit(0);<br />
<br />
default:<br />
printf("Invalid Option..\n");<br />
<br />
}<br />
}<br />
<br />
void main()<br />
{<br />
system("cls");<br />
while(1)<br />
menu();<br />
getch();<br />
<br />
}<br />
<br />
int AddToQueue(struct queuelist* q, int data)<br />
{<br />
struct queuelist* temp;<br />
q = head;<br />
if(q == NULL)<br />
{<br />
printf("First member in queue.\n");<br />
q = (struct queuelist*)malloc(sizeof(struct queuelist));<br />
if(q == NULL)<br />
{<br />
printf("Not enough memory. Stopping...\n");<br />
return -1;<br />
}<br />
else<br />
{<br />
q->intData = data;<br />
q->valid=1;<br />
q->next=NULL;<br />
head = q;<br />
tail = q;<br />
<br />
}<br />
<br />
<br />
}<br />
else<br />
{<br />
q=head;<br />
while(q->next!=NULL) q = q->next;<br />
<br />
temp = (struct queuelist*)malloc(sizeof(struct queuelist));<br />
if(temp == NULL)<br />
{<br />
printf("Not enough memory. Quitting...\n");<br />
return -1;<br />
}<br />
else<br />
{<br />
temp->intData = data;<br />
temp->next=NULL;<br />
q->next = temp;<br />
q = q->next;<br />
q->valid = 1;<br />
tail = q;<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
return data;<br />
}<br />
<br />
<br />
void DisplayQueue(struct queuelist* queue)<br />
{<br />
system("cls");<br />
queue = head;<br />
if(queue == NULL || queue->valid != 1)<br />
{<br />
printf("Empty Queue");<br />
}<br />
else<br />
{<br />
while(queue != NULL)<br />
{<br />
printf("||%d|%x||->",queue->intData,queue->next);<br />
queue = queue->next;<br />
}<br />
<br />
}<br />
printf("\n");<br />
<br />
}<br />
<br />
int RemoveFromQueue(struct queuelist* queue)<br />
{<br />
<br />
struct queuelist* prev;<br />
struct queuelist* second;<br />
queue = head;<br />
if(queue->valid !=1 || queue==NULL)<br />
{<br />
printf("Queue Exhausted. No members.\n");<br />
return -1;<br />
}<br />
else<br />
{<br />
queue = head;<br />
prev = queue;<br />
queue = queue->next;<br />
second = queue;<br />
head = queue;<br />
printf("Popped off : %d at %x\n",prev->intData, prev->next);<br />
prev->next = NULL;<br />
free(prev);<br />
}<br />
<br />
return prev->intData;<br />
<br />
}<br />
int DeleteQueue(struct queuelist* queue)<br />
{<br />
struct queuelist* prev;<br />
queue = head;<br />
if(queue == NULL)<br />
return -1;<br />
while(queue!=NULL)<br />
{<br />
prev = queue;<br />
queue = queue->next;<br />
queue->valid=0;<br />
free(prev);<br />
}<br />
<br />
return 1;<br />
}
Tis now working perfectly. I will return with wrappers around this so that these could be included in a class.
Regards,
Sreekanth Muralidharan,;P
Software Consultant.
|
|
|
|
|
Hello
See the code in C++ for linked list implementation of a queue.
<code> #include <iostream.h>
#include <stdlib.h>
#include <process.h>
#include <conio.h>
#include <dos.h>
struct queuelist
{
int intData;
int valid;
struct queuelist* next;
};
struct queuelist *head, *tail;
class CNode
{
private:
struct queuelist* queue;
public:
int AddToQueue(int);
int PopFromQueue();
int DeleteQueue();
void DisplayQueue();
};
void menu();
void menu()
{
textcolor(WHITE);
cout<<" Queue Manipulation Menu"<<endl;
cout<<"........................"<<endl<<endl;
cout<<"1. Add member to queue."<<endl;
cout<<"2. Extract next member."<<endl;
cout<<"3. Delete whole queue."<<endl;
cout<<"4. Help"<<endl;
cout<<"5. Display queue contents."<<endl;
cout<<"6. Quit."<<endl;
}
void main()
{
clrscr();
int data;
int option;
CNode node;
while(1)
{
menu();
cout<<"OPTION: ";
cin>>option;
cout<<endl;
switch(option)
{
case 1:
cout<<"Member: ";
cin>>data;
if(node.AddToQueue(data)==-1)
cout<<"Could not add.."<<endl;
else
cout<<"Added.."<<endl;
break;
case 2:
int pop=0;
clrscr();
cout<<"Extract next member."<<endl;
pop = node.PopFromQueue();
if(pop!=-1)
cout<<node.PopFromQueue();
break;
case 3:
clrscr();
node.DeleteQueue();
break;
case 4:
cout<<"Under Construction."<<endl;
break;
case 5:
clrscr();
cout<<"Queue Contents."<<endl;
node.DisplayQueue();
break;
case 6:
exit(0);
default:
textcolor(RED);
cout<<"Invalid Option.."<<endl;
break;
}
}
getch();
}
int CNode::AddToQueue(int data)
{
struct queuelist* q;
struct queuelist* temp;
q = head;
if(q == NULL)
{
cout<<"First member in queue."<<endl;
temp = (struct queuelist*)malloc(sizeof(struct queuelist));
if(temp == NULL)
{
textcolor(RED);
cout<<"Not enough memory. Stopping..."<<endl;
return -1;
}
else
{
temp->intData = data;
temp->next=NULL;
temp->valid=1;
q->next = temp;
head = temp;
tail = temp;
q = temp;
}
}
else
{
while(q->next!=NULL) q=q->next;
temp = (struct queuelist*)malloc(sizeof(struct queuelist));
if(temp == NULL)
{
textcolor(RED);
cout<<"Not enough memory. Quitting..."<<endl;
return -1;
}
else
{
temp->intData = data;
temp->next=NULL;
q->next = temp;
q = q->next;
q->valid = 1;
tail = q;
}
}
return 1;
}
void CNode::DisplayQueue()
{
struct queuelist* queue;
queue = head;
if(queue == NULL || queue->valid != 1)
{
textcolor(RED);
cout<<"Empty Queue";
}
else
{
while(queue != NULL)
{
if(queue->next!=0)
cout<<"||"<<queue->intData<<"|"<<queue->next;
else
cout<<"||"<<queue->intData<<"|NULL||->";
queue = queue->next;
}
}
cout<<endl;
}
int CNode::PopFromQueue()
{
int tempdat=0;
struct queuelist* queue;
struct queuelist* prev;
queue = head;
if(queue->valid !=1)
{
textcolor(RED);
cout<<"Queue Exhausted. No members."<<endl;
return -1;
}
else
{
queue = head;
prev = queue;
queue = queue->next;
head = queue;
}
tempdat = prev->intData;
prev->next=NULL;
free(prev);
return tempdat;
}
int CNode::DeleteQueue()
{
struct queuelist* prev;
queue = head;
while(queue!=NULL)
{
prev = queue;
queue = queue->next;
queue->valid=0;
free(prev);
}
return 1;
}</code>
Bye,
Sreekanth Muralidharan
|
|
|
|
|
Much better, but still shows confusion.
Now you have C and C++ mixed all up together in a Frakeinstineon (the monster) kind of way.
You need to know a little more about C programing and for C++ programing I recommend the Bruce Eckel series of books, since he is good at explaning it. Also, Bruce Eckel has a web-site that has copies of his books in electronic form that you can download (recomend purchasing them though).
After reading you bio and seeing how well you did, I have decided to write my version and will send it to you (when finished).
Mean while:
1) queuelist is still a node.
2) CNode is not a node it represents the list.
3) The fuctions that require a return value do not return a success value.
4) The getch() function will never be reached, because you are still using exit() to exit from the program.
typedef struct tagNode
{
struct tagNode* pNext;
int intData;
} NODE;
static NODE* g_pHead;
int AddNode(int intData);
int DisplayList();
int DeleteNode();
void DeleteAll();
class CIntList
{
struct NODE
{
struct NODE* pNext;
int intData;
};
NODE* m_pHead;
public:
int AddNode(int intData);
int DisplayList();
int DeleteNode();
void DeleteAll();
CIntList() : m_pHead(NULL) {}
~CIntList() { DeleteAll(); }
};
Good Luck!
INTP
|
|
|
|
|
I'm working with MFC42 (the one that came with VS6). Is there any way to gray out buttons in the toolbar which have a handler ?
I have got a base class for all my dialog boxes, which handles the messages. So every dialog box has got a function which handles the Toolbar messages altough the handler doesn't do anything useful. The users want the buttons with unuseful handlers grayed out, so i have to do this programmatically.
Any ideas ?
All the label says is that this stuff contains chemicals "... known to the State of California to cause cancer in rats and low-income test subjects." Roger Wright http://www.codeproject.com/lounge.asp?select=965687&exp=5&fr=1#xx965687xx
|
|
|
|
|
Every ToolbUtton must have A ID .
via Using these Function you can disable them
let Button id you want to disable is ID_BUTTON1
then here is little piece of Code.
CButton *But=(CButton*)this->GetDlgItem(ID_BUTTON1);<br />
<br />
if(But)<br />
{<br />
But->EnableWindow(FALSE);<br />
}
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
You should implement the <a href="http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_on_update_command_ui.asp">ON_UPDATE_COMMAND_UI</a> [<a href="http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_on_update_command_ui.asp" target="_blank" title="New Window">^</a>] handler for your button's control ID and then call pCmdUI->Enable( false ) in that handler.
--
Affordable Windows-based CMS: www.zeta-producer.de/enu
|
|
|
|