|
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
|
|
|
|
|
I do create a CListCtrl (yes, really this is no voting joke! ) with the WS_BORDER style inside a control and later put it into a dialog box by code, too.
The problem is that the control that I create by hand has a 1 pixel black border on XP but not the 1 pixel blue border (i.e. the Windows XP themed border) when being dropped visually on a dialog box.
Question: Can anyone tell me how to acchieve the themed version when creating a control programatically?
Thanks!
--
Affordable Windows-based CMS: www.zeta-producer.de/enu
|
|
|
|
|
Got it myself :
The Control does not have the WS_BORDER style but rather the extended WS_EX_CLIENTEDGE style. Then it looks correctly.
--
Affordable Windows-based CMS: www.zeta-producer.de/enu
|
|
|
|
|
Hi guys ...
I have two questions for you:
1. How can i detect if SP1, or SP2 is installed on a machine(and if is the final release, not beta)
and is there any way to know if the OS is in "Safe Mode" ?
2. I have to install some files from my app, but they are protected by Windows File Protection. Is there any way
to install them? [w/o copying them from safe mode]
Thanks ...
|
|
|
|
|
I this Can help you out
OSVERSIONINFO
The OSVERSIONINFO data structure contains operating system version information. The information includes major and minor version numbers, a build number, a platform identifier, and descriptive text about the operating system. This structure is used with the GetVersionEx function.
<br />
typedef struct _OSVERSIONINFO{ <br />
DWORD dwOSVersionInfoSize; <br />
DWORD dwMajorVersion; <br />
DWORD dwMinorVersion; <br />
DWORD dwBuildNumber; <br />
DWORD dwPlatformId; <br />
TCHAR szCSDVersion[ 128 ]; <br />
} OSVERSIONINFO ;
AND
lAST pARAMETER
szCSDVersion
Windows NT/2000/XP: Contains a null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack installed on the system. If no Service Pack has been installed, the string is empty.
Windows 95/98/Me: Contains a null-terminated string that indicates additional version information. For example, " C" indicates Windows 95 OSR2 and " A" indicates Windows 98 Second Edition
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi every body.
How i'am program same MSN Messenger when has user login.
a program stay in system tray popup dialog message same
MSN Messanger or Norton Antivirus
Thank you.
|
|
|
|
|
My error!
First time!i choice Two.m_cbodata is Two.
Second time!i choice One.m_cbodata is Two.
When i choice ,my Combo Box data is not change.
I don't know what happen.
pls help me.
My code is following......
//MyView.h
public:
//{{AFX_DATA(CMyView)
CString m_cbodata;
//}}AFX_DATA
//MyView.cpp
void Click()
{
UpdateData(TRUE);
if (m_cbodata=="One")
{
AfxMessageBox("One");
}
if (m_cbodata=="Two")
{
AfxMessageBox("Two");
}
}
|
|
|
|
|
i found my error!!!
i change following code!!!!
//MyView.cpp
if (0==m_ctrldevice.GetCurSel( ))
{
AfxMessageBox("One");
}
if (1==m_ctrldevice.GetCurSel( ))
{
AfxMessageBox("Two");
}
|
|
|
|
|
how about this:
CString str;
str.Format("%d",m_ctrldevice.GetCurSel() + 1);
AfxMessageBox(str);
this will display a messagebox with "1","2", or whatever the cursel is.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hi !
I'm facing many problems (app crashs) when my app is compiled in release mode (problems I don't have in debug mode). I noticed that removing some const_cast improved the situation.
This makes me wonder : am I allowed to use const_cast ? How can I spot the situations where const_cast should be avoided ? If const_cast is dangerous, why is it provided ?
Thanks for your enlightment !
Jerome
|
|
|
|
|
hian So Jerome BAck!!!!
so any way here you's Answer,As MSDN states that,i have maked sentence bold which might be causing problem in your program
pointer to any object type or a pointer to a data member can be explicitly converted to a type that is identical except for the const, volatile, and __unaligned qualifiers. For pointers and references, the result will refer to the original object. For pointers to data members, the result will refer to the same member as the original (uncast) pointer to data member. Depending on the type of the referenced object, a write operation through the resulting pointer, reference, or pointer to data member might produce undefined behavior.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi everybody,
Currently i am thinking how to program a PC Booking/Reservation System for an office of 100 PCs where user login is controled by Windows Active Directory.
I have little idea about AD login control, anybody can tell me where to start?
Thanks
JW
DJ
|
|
|
|
|
well.....i had a doubt earlier regarding how i can access data from different classes.....i got the answer.....though that exactly didnt solve my answer.....
u c i am making a dialog box.....that is to load a picture.....and upon moving the mouse upon it.....it is supposed to change the pictures......(bacially these pics are frames of a volume control).....what i have done is that i have loaded the pics.....into the dc memory(and made it compactible).....so by bitblt it displays.....it workz as well.....
my problem is.....i have many such controls......so i have derived a class from the Cstatic class and by using the concept of subclassing.....i can get the mouse controls for the particular control.....
but to bitblt it i have to call the variable that pointz to the frame of that picture......but i have declared the variables that hold the frames of this in the main CXyzDlg::OnInitDialog() .....how do i access this variables from th derived class THAT I HAVE CREATED?????
PLEASE HELP!!!!!!
|
|
|
|
|
could you be more specific, even give some code exemple and point out the error
|
|
|
|
|
ok......
this os what i have declared in the CXyzDlg.h
<br />
CSize m_size;<br />
CSize m_size1;<br />
<br />
CPoint m_pt;<br />
CDC m_dcMem;
CDC m_dcMempotI[32];
<br />
HBITMAP m_hBmpOld;
HBITMAP m_hBmpNew;
BITMAP m_bmInfo;
<br />
BITMAP m_bmInfo1; <br />
<br />
this is what i have added in the CXyzDlg::OnPaint()......here i have called the variables that points to the picture in the dc memory
<br />
void CCreamzDlg::OnPaint() <br />
{<br />
if (IsIconic())<br />
{<br />
CPaintDC dc(this);
<br />
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);<br />
<br />
int cxIcon = GetSystemMetrics(SM_CXICON);<br />
int cyIcon = GetSystemMetrics(SM_CYICON);<br />
CRect rect;<br />
GetClientRect(&rect);<br />
int x = (rect.Width() - cxIcon + 1) / 2;<br />
int y = (rect.Height() - cyIcon + 1) / 2;<br />
<br />
dc.DrawIcon(x, y, m_hIcon);<br />
}<br />
else<br />
{<br />
<br />
<br />
CPaintDC dc(this);<br />
dc.BitBlt(offsetx,offsety,m_size.cx+50,m_size.cy+50,&m_dcMem, 2, 0,SRCCOPY);<br />
<br />
dc.BitBlt(offsetx1,offsety1,m_size1.cx,m_size1.cy,&m_dcMempotI[m_i], -14, -13,SRCCOPY);<br />
<br />
dc.BitBlt(offsetx2,offsety2,m_size1.cx,m_size1.cy,&m_dcMempotI[m_j], -14, -13,SRCCOPY);<br />
CDialog::OnPaint();<br />
<br />
<br />
}<br />
}<br />
<br />
the code that i am showing here is the one that works.......that is the one that doesnot use subclassing.....
i need subclassing feature coz the only action that i can get with a ststic control is just the event "On Clicked()"....but i need the mousemove function as well in the static window....so for that i derive a class from the base class CStatic....and add the mouse movements into it(subclassing).....the problem is that even in this derived class i have put in the WM_PAINT message as well....so that it can be automatically updated.....and thatz when the problem arises.....
i am not able to call the
dc.BitBlt(offsetx2,offsety2,m_size1.cx,m_size1.cy,&m_dcMempotI[m_j], -14, -13,SRCCOPY);
coz inside it the the derived class the variable : ,&m_dcMempotI , m_j ,offsetx2,offsety2,m_size1 are not defined...
what do i do....
if i were to put the dcmemory variable in a class....each time i create an object....a lot of memory is taken...coz all the frames of the volume controls get created again and again.....but tere is a need only for one.....
i hope u understood the prob.....
this is what i had written in the CXyzDlg::OnInitDialog()
in this there are three static windowz that i have created (one background bitmap,two controlz bitmap)
with the variables m_st1 ,.m_st3 ,m.st4 respectively being the static variables linked to the static windows.
<br />
BOOL CCreamzDlg::OnInitDialog()<br />
{<br />
CDialog::OnInitDialog();<br />
<br />
<br />
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);<br />
ASSERT(IDM_ABOUTBOX < 0xF000);<br />
<br />
CMenu* pSysMenu = GetSystemMenu(FALSE);<br />
if (pSysMenu != NULL)<br />
{<br />
CString strAboutMenu;<br />
strAboutMenu.LoadString(IDS_ABOUTBOX);<br />
if (!strAboutMenu.IsEmpty())<br />
{<br />
pSysMenu->AppendMenu(MF_SEPARATOR);<br />
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);<br />
}<br />
}<br />
<br />
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
<br />
m_i=0;<br />
m_j=0;<br />
m_check=FALSE;<br />
<br />
<br />
m_DragOn=FALSE;<br />
<br />
<br />
CClientDC dc(this);<br />
m_dcMem.CreateCompatibleDC( &dc );<br />
<br />
sourcex=sourcey=0;<br />
<br />
<br />
m_hBmpNew = (HBITMAP) LoadImage(<br />
AfxGetInstanceHandle(),
"c:\\mm.bmp",
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION|LR_LOADFROMFILE); <br />
<br />
if( m_hBmpNew == NULL )<br />
{<br />
AfxMessageBox("Load Image Failed");<br />
}<br />
<br />
else {<br />
<br />
<br />
m_st1.GetClientRect( &rectStaticClient );<br />
rectStaticClient.NormalizeRect();<br />
m_size.cx=rectStaticClient.Size().cx;<br />
m_size.cy=rectStaticClient.Size().cy;<br />
m_size.cx = rectStaticClient.Width();
m_size.cy = rectStaticClient.Height();
<br />
m_st1.ClientToScreen( &rectStaticClient );<br />
ScreenToClient( &rectStaticClient);<br />
<br />
m_pt.x = rectStaticClient.left;<br />
m_pt.y = rectStaticClient.top;<br />
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );<br />
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew ) );<br />
offsetx= m_pt.x;<br />
offsety=m_pt.y; <br />
}<br />
<br />
<br />
m_dcMempotI[0].CreateCompatibleDC( &dc );<br />
<br />
strcpy(m_filename,"E:\\projectz_infoz\\minimax_potz\\modified\\pot1\\pot");<br />
_itoa( 0, m_charz, 10 );<br />
strcat(m_filename,m_charz);<br />
strcat(m_filename,".bmp");<br />
<br />
<br />
m_hBmpNew = (HBITMAP) LoadImage(<br />
AfxGetInstanceHandle(),
m_filename,
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION|LR_LOADFROMFILE); <br />
<br />
if( m_hBmpNew == NULL )<br />
{<br />
AfxMessageBox("Load Image Failed");<br />
}<br />
<br />
else {<br />
m_st3.GetClientRect( &rectStaticClient );<br />
rectStaticClient.NormalizeRect();<br />
m_size1.cx=rectStaticClient.Size().cx;<br />
m_size1.cy=rectStaticClient.Size().cy;<br />
m_size1.cx = rectStaticClient.Width();
m_size1.cy = rectStaticClient.Height();
<br />
m_st3.ClientToScreen( &rectStaticClient );<br />
ScreenToClient( &rectStaticClient);<br />
<br />
m_pt.x = rectStaticClient.left;<br />
m_pt.y = rectStaticClient.top;<br />
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );<br />
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMempotI[0], m_hBmpNew ) );<br />
offsetx1= m_pt.x;<br />
offsety1=m_pt.y; <br />
}<br />
<br />
<br />
for(m_i=1;m_i<=31;m_i++)<br />
{<br />
<br />
m_dcMempotI[m_i].CreateCompatibleDC( &dc );<br />
<br />
strcpy(m_filename,"E:\\projectz_infoz\\minimax_potz\\modified\\pot1\\pot");<br />
_itoa( m_i, m_charz, 10 );<br />
strcat(m_filename,m_charz);<br />
strcat(m_filename,".bmp");<br />
<br />
<br />
m_hBmpNew = (HBITMAP) LoadImage(<br />
AfxGetInstanceHandle(),
m_filename,
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION|LR_LOADFROMFILE); <br />
<br />
if( m_hBmpNew == NULL )<br />
{<br />
AfxMessageBox("Load Image Failed");<br />
}<br />
<br />
else {<br />
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );<br />
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMempotI[m_i], m_hBmpNew ) );<br />
}<br />
<br />
}
<br />
m_i=0;<br />
<br />
<br />
<br />
m_st4.GetClientRect( &rectStaticClient1 );<br />
rectStaticClient.NormalizeRect();<br />
m_size1.cx=rectStaticClient.Size().cx;<br />
m_size1.cy=rectStaticClient.Size().cy;<br />
m_size1.cx = rectStaticClient.Width();
m_size1.cy = rectStaticClient.Height();
<br />
m_st4.ClientToScreen( &rectStaticClient1 );<br />
ScreenToClient( &rectStaticClient1);<br />
<br />
m_pt.x = rectStaticClient1.left;<br />
m_pt.y = rectStaticClient1.top;<br />
offsetx2= m_pt.x;<br />
offsety2=m_pt.y; <br />
<br />
<br />
<br />
return TRUE;
}<br />
<br />
please get me a solution......anyone....
if anyone has got a bettr way of doing this without subclassing.....that is also ok as well....
HELP!!!!!
|
|
|
|
|
hi all,
I want to Right Click on the different static Controls..(Labels,..)
How to do that using Visual C++?
Can anybody please help me?
Thanks in advance..
|
|
|
|
|
...
hi there...
this is how i do it....
well.....first derive a class say "CMystatic"from the base class CStatic class using the 'ADD CLASS' option in the wizard.....
after u do this.....
again take the wizard....then take the "message maps option" and in that select the class name that u have just derived (here called as CMystatic) from the "class name" combo box......
then.....in the messages option select the WM_LBUTTONDOWN.....by doubleclicking on this the wizard automatically loads the handler responsible when the left button is clicked on the static control.....
if have still doubt check up.....
Create your own controls - the art of subclassing
By Chris Maunder .....which iz a very informative topic available in code project .....
cheerz....
|
|
|
|
|