Click here to Skip to main content
15,901,122 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Combo Box Error Pin
vc-programmer-7-Nov-04 23:16
vc-programmer-7-Nov-04 23:16 
GeneralRe: Combo Box Error Pin
BlackDice8-Nov-04 3:54
BlackDice8-Nov-04 3:54 
Generalconst_cast Pin
Jerome Conus7-Nov-04 21:29
Jerome Conus7-Nov-04 21:29 
GeneralRe: const_cast Pin
ThatsAlok7-Nov-04 22:17
ThatsAlok7-Nov-04 22:17 
QuestionAccess Active Directory to Control PC User Logon? Pin
DengJW7-Nov-04 19:17
DengJW7-Nov-04 19:17 
Generalnewbie here: doubt relating how i can create a global data Pin
namaskaaram7-Nov-04 18:58
namaskaaram7-Nov-04 18:58 
GeneralRe: newbie here: doubt relating how i can create a global data Pin
Anonymous7-Nov-04 21:57
Anonymous7-Nov-04 21:57 
GeneralRe: newbie here: doubt relating how i can create a global data Pin
namaskaaram8-Nov-04 16:51
namaskaaram8-Nov-04 16:51 
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;            // Compatible Memory DC for dialog<br />
	CDC m_dcMempotI[32];            // Compatible Memory DC for dialog<br />
	<br />
	HBITMAP m_hBmpOld;    // Handle of old bitmap to save<br />
    HBITMAP m_hBmpNew;    // Handle of new bitmap from file<br />
    BITMAP m_bmInfo;        // Bitmap Information structure<br />
<br />
    BITMAP m_bmInfo1;        // Bitmap Information structure<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); // device context for painting<br />
<br />
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);<br />
<br />
		// Center icon in client rectangle<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 />
		// Draw the icon<br />
		dc.DrawIcon(x, y, m_hIcon);<br />
	}<br />
	else<br />
	{<br />
<br />
<br />
		//Add the following Code <br />
        CPaintDC dc(this);<br />
        dc.BitBlt(offsetx,offsety,m_size.cx+50,m_size.cy+50,&m_dcMem, 2, 0,SRCCOPY);<br />
<br />
	//if(m_check==TRUE)<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 />
	// Add "About..." menu item to system menu.<br />
<br />
	// IDM_ABOUTBOX must be in the system command range.<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 />
	// Set the icon for this dialog.  The framework does this automatically<br />
	//  when the application's main window is not a dialog<br />
	SetIcon(m_hIcon, TRUE);			// Set big icon<br />
	SetIcon(m_hIcon, FALSE);		// Set small icon<br />
	<br />
	// TODO: Add extra initialization here<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 />
//THIS IS USED TO LOAD THE BACKGROUND BITMAP INTO THE DC MEMORY<br />
<br />
	m_hBmpNew = (HBITMAP) LoadImage(<br />
    AfxGetInstanceHandle(),   // handle to instance<br />
    "c:\\mm.bmp",  // name or identifier of the image .say"C:\\NewFolder\\1.bmp"<br />
    IMAGE_BITMAP,        // image types<br />
    0,     // desired width<br />
    0,     // desired height<br />
    LR_CREATEDIBSECTION|LR_LOADFROMFILE); <br />
<br />
    if( m_hBmpNew == NULL )<br />
    {<br />
        AfxMessageBox("Load Image Failed");<br />
    }<br />
    <br />
    // put the HBITMAP info into the CBitmap (but not the bitmap itself)<br />
    else {<br />
<br />
//GET THE PROPERTIES OF THE STATIC WINDOW(FIRST WINDOW)<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();    // zero based<br />
        m_size.cy = rectStaticClient.Height();    // zero based<br />
<br />
        // Convert to screen coordinates using static as base,<br />
        // then to DIALOG (instead of static) client coords <br />
        // using dialog as base<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 />
//       InvalidateRect(&rectStaticClient);<br />
		}<br />
		<br />
//==============================================================================	<br />
//THIS IS USED TO LOAD THE FIRST FRAME OF THE BITMAP(FRAME 1 OF THE VOLUME CONTROL) INTO THE DC MEMORY<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(),   // handle to instance<br />
    m_filename,  // name or identifier of the image .say"C:\\NewFolder\\1.bmp"<br />
    IMAGE_BITMAP,        // image types<br />
    0,     // desired width<br />
    0,     // desired height<br />
    LR_CREATEDIBSECTION|LR_LOADFROMFILE); <br />
<br />
    if( m_hBmpNew == NULL )<br />
    {<br />
        AfxMessageBox("Load Image Failed");<br />
    }<br />
    <br />
    // put the HBITMAP info into the CBitmap (but not the bitmap itself)<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();    // zero based<br />
        m_size1.cy = rectStaticClient.Height();    // zero based<br />
<br />
        // Convert to screen coordinates using static as base,<br />
        // then to DIALOG (instead of static) client coords <br />
        // using dialog as base<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 />
 //      InvalidateRect(&rectStaticClient);<br />
		}<br />
<br />
<br />
//////////////////////////////////////////////////////////////////////////////////<br />
//THIS IS USED TO LOAD THE OTHER FRAMES OF THE BITMAP( VOLUME CONTROL) INTO THE DC MEMORY<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(),   // handle to instance<br />
    m_filename,  // name or identifier of the image .say"C:\\NewFolder\\1.bmp"<br />
    IMAGE_BITMAP,        // image types<br />
    0,     // desired width<br />
    0,     // desired height<br />
    LR_CREATEDIBSECTION|LR_LOADFROMFILE); <br />
<br />
    if( m_hBmpNew == NULL )<br />
    {<br />
        AfxMessageBox("Load Image Failed");<br />
    }<br />
    <br />
    // put the HBITMAP info into the CBitmap (but not the bitmap itself)<br />
    else {<br />
      GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );<br />
      VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMempotI[m_i], m_hBmpNew )  );<br />
//    InvalidateRect(&rectStaticClient);  <br />
	}<br />
<br />
}//end of for(m_i=1;m_i<=31;m_i++)<br />
<br />
m_i=0;<br />
//////////////////////////////////////////////////////////////////////////////////<br />
<br />
//================================================================================<br />
<br />
//================================================================================<br />
//GET THE PROPERTIES OF THE STATIC WINDOW(SECOND WINDOW)<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();    // zero based<br />
        m_size1.cy = rectStaticClient.Height();    // zero based<br />
<br />
        // Convert to screen coordinates using static as base,<br />
        // then to DIALOG (instead of static) client coords <br />
        // using dialog as base<br />
        m_st4.ClientToScreen( &rectStaticClient1 );<br />
        ScreenToClient( &rectStaticClient1);<br />
<br />
        m_pt.x = rectStaticClient1.left;<br />
        m_pt.y = rectStaticClient1.top;<br />
//        GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );<br />
//        VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMempotI[0], m_hBmpNew )  );<br />
        offsetx2= m_pt.x;<br />
        offsety2=m_pt.y;    <br />
//================================================================================<br />
<br />
<br />
	return TRUE;  // return TRUE  unless you set the focus to a control<br />
}<br />
<br />





please get me a solution......anyone....
Confused | :confused:
if anyone has got a bettr way of doing this without subclassing.....that is also ok as well....


HELP!!!!!
Sigh | :sigh:
QuestionHow to Right Click using Mouse on the Static Controls? Pin
pubududilena7-Nov-04 17:29
pubududilena7-Nov-04 17:29 
AnswerRe: How to Right Click using Mouse on the Static Controls? Pin
namaskaaram7-Nov-04 18:21
namaskaaram7-Nov-04 18:21 
AnswerRe: How to Right Click using Mouse on the Static Controls? Pin
namaskaaram8-Nov-04 23:46
namaskaaram8-Nov-04 23:46 
QuestionWhy it happens so ? Pin
pc_dev7-Nov-04 17:20
pc_dev7-Nov-04 17:20 
AnswerRe: Why it happens so ? Pin
balajeedurai7-Nov-04 17:56
balajeedurai7-Nov-04 17:56 
GeneralRe: Why it happens so ? Pin
pc_dev7-Nov-04 18:57
pc_dev7-Nov-04 18:57 
GeneralMSFlex Grid Row Selection Pin
balajeedurai7-Nov-04 17:09
balajeedurai7-Nov-04 17:09 
GeneralRe: MSFlex Grid Row Selection Pin
pc_dev7-Nov-04 20:33
pc_dev7-Nov-04 20:33 
GeneralRe: MSFlex Grid Row Selection Pin
balajeedurai7-Nov-04 20:40
balajeedurai7-Nov-04 20:40 
GeneralHandling expanding message for SECTreeCtrl Pin
Ian Bowler7-Nov-04 16:33
Ian Bowler7-Nov-04 16:33 
GeneralRe: Handling expanding message for SECTreeCtrl Pin
Ravi Bhavnani7-Nov-04 19:09
professionalRavi Bhavnani7-Nov-04 19:09 
GeneralRe: Handling expanding message for SECTreeCtrl Pin
Ian Bowler7-Nov-04 21:15
Ian Bowler7-Nov-04 21:15 
GeneralAdvice Required Pin
Imtiaz Murtaza7-Nov-04 15:51
Imtiaz Murtaza7-Nov-04 15:51 
GeneralRe: Advice Required Pin
bryce7-Nov-04 17:07
bryce7-Nov-04 17:07 
GeneralRe: Advice Required Pin
Imtiaz Murtaza7-Nov-04 17:20
Imtiaz Murtaza7-Nov-04 17:20 
GeneralRe: Advice Required Pin
bryce7-Nov-04 17:24
bryce7-Nov-04 17:24 
GeneralRe: Advice Required Pin
Member 3076127-Nov-04 19:20
Member 3076127-Nov-04 19:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.