[VC++ UI Need Help] Dynamic Controls are getting disabled automatically after some time.

Hi Team,



We are facing one problem in User Interface. Can you please help us to
fix.



Issue:  Dynamic Controls are getting disabled automatically after some
time.


Team, we are loading the gif image as bitmap for main dialog and
putting all the controls on it dynamically



After launching the application the controls, text are getting disabled
automatically only the main image left over.



This is critical at this time; your kind help is really appreciable.



For your reference



 You can go through the following Partial code, how we have
implemented.



Loading Image





 CGifImageSet gifImageSet;

                        CDC *pDC = GetDC();



                        strMainImage =
Utilities::GetFullPath(strSkinXmlFolderPath, strMainImage);

        gifImageSet.LoadGIF(strMainImage.GetBuffer());

                        if(gifImageSet.nImages > 0)

                                    gifImageSet.img[0]->InitBitmap(pDC,
&m_mainBmp);

                        gifImageSet.DeleteImageSet();





OnPaint Function



void CPebbleBeachDlg::OnPaint()

{

            //TRACE_ENTRY("CPebbleBeachDlg OnPaint Entering");

            try{

                        if (IsIconic())

                        {

                                    CPaintDC dc(this); // device
context for painting



                                    SendMessage(WM_ICONERASEBKGND,
reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);



                                    // Center icon in client rectangle

                                    int cxIcon =
GetSystemMetrics(SM_CXICON);

                                    int cyIcon =
GetSystemMetrics(SM_CYICON);

                                    CRect rect;

                                    GetClientRect(&rect);

                                    int x = (rect.Width() - cxIcon + 1)
/ 2;

                                    int y = (rect.Height() - cyIcon +
1) / 2;



                                    // Draw the icon

                                    dc.DrawIcon(x, y, m_hIcon);

                        }

                        else

                        {

                                    CDialog::OnPaint();



                                    CPaintDC dc(this); // device
context for painting



                                    OnEraseBkgnd( &dc );

                                    ReleaseDC(&dc);

                        }

            }catch(...)

            {

                        //Utilities::FunctionalLogin("\nOnPaint
Crashed");

                        TRACE_ERROR("CPebbleBeachDlg OnPaint Crashed");


APP_LOG_WRITE_EXCEPTION("CPebbleBeachDlg::OnPaint");

            }

//          TRACE_EXIT;



}





OnEraseBackGround Function



BOOL CPebbleBeachDlg::OnEraseBkgnd(CDC* pDC)

{

                        //Utilities::FunctionalLogin("\nOnEraseBkgnd
Entering");

            //TRACE_ENTRY("OnEraseBkgnd Entering");

            try{

                        BOOL bRetValue=CDialog::OnEraseBkgnd(pDC);



            /*          if ( pDC == 0 )

                        {

                                    CPaintDC dc(this);

                                    pDC = &dc;

                        }*/

                        CRect rect;

                        if (!m_mainBmp.GetSafeHandle())

                                    return bRetValue;



                        GetClientRect(rect);

                        CDC dc;

                        dc.CreateCompatibleDC(pDC);

                        HBITMAP    pbmpOldBmp = NULL;

                        pbmpOldBmp = (HBITMAP)::SelectObject(dc.m_hDC,
m_mainBmp);

                        CSize bmpSize =
Utilities::GetBitmapSize(&m_mainBmp);

                        if (m_windowSize.cx != 0 && m_windowSize.cy
!=0)

                        {

                                    GetWindowRect(rect);

                                    //rect.left = 0; rect.top = 0;

                                    rect.right = rect.left +
m_windowSize.cx;

                                    rect.bottom = rect.top +
m_windowSize.cy;

                                    //AdjustWindowSize(m_windowSize);

                        }

                        pDC->BitBlt(0, 0, rect.Width(), rect.Height(),
&dc, 0, 0, SRCCOPY);

                        pDC->StretchBlt(0, 0, rect.Width(),
rect.Height(), &dc, 0, 0, bmpSize.cx, bmpSize.cy, SRCCOPY);

                        ::SelectObject(dc.m_hDC, m_mainBmp);

                        //ShowWindow(SW_MAXIMIZE);

                        return bRetValue;

            }catch(...)

            {

                        //Utilities::FunctionalLogin("\nOnEraseBkgnd
Crashed");

                        TRACE_ERROR("OnEraseBkgnd Crashed");


APP_LOG_WRITE_EXCEPTION("CPebbleBeachDlg::OnEraseBkgnd");

            }

                        //Utilities::FunctionalLogin("\nOnEraseBkgnd
Exit");

//          TRACE_EXIT;

            return FALSE;

}

 

 

Awaitingly

 

Thangaraju S

0
10/6/2006 4:00:55 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
448 Views

Similar Articles

[PageSpeed] 14

Several problems with your code:

1) Remove OnPaint(), it's not needed.  If you remove all the lines indicated 
below, you will have nothing left.  Just get rid of the entire OnPaint 
method.

> void CPebbleBeachDlg::OnPaint()
> {
>            //TRACE_ENTRY("CPebbleBeachDlg OnPaint Entering");
>            try{
>                        if (IsIconic())
>                        {
>                                [...]
>                        }
>                        else
>                        {
>                                    Dialog::OnPaint();        // <-- REMOVE 
> THIS!  NEVER CALL ANCESTOR ONPAINT()
>                                    CPaintDC dc(this); // device context 
> for painting
>                                    OnEraseBkgnd( &dc );    // <-- REMOVE 
> THIS!  Windows calls OnEraseBkgnd() for you
>                                    ReleaseDC(&dc);        / /    <--  
> REMOVE THIS!  dc is automatically released in ~CPaintDC!
>                        }
>            }catch(...)
>            {
>                [...]
>            }
>
> //          TRACE_EXIT;
> }
>
>


2) Your OnEraseBkgnd() should paint the gifImageSet, not call the ancestor 
class which doesn't paint any image!


-- David


0
dc2983 (3206)
10/7/2006 4:40:24 AM
Hi,

I tried with this option its not working.

Thank you,
Thangaraju S


David Ching wrote:

> Several problems with your code:
>
> 1) Remove OnPaint(), it's not needed.  If you remove all the lines indicated
> below, you will have nothing left.  Just get rid of the entire OnPaint
> method.
>
> > void CPebbleBeachDlg::OnPaint()
> > {
> >            //TRACE_ENTRY("CPebbleBeachDlg OnPaint Entering");
> >            try{
> >                        if (IsIconic())
> >                        {
> >                                [...]
> >                        }
> >                        else
> >                        {
> >                                    Dialog::OnPaint();        // <-- REMOVE
> > THIS!  NEVER CALL ANCESTOR ONPAINT()
> >                                    CPaintDC dc(this); // device context
> > for painting
> >                                    OnEraseBkgnd( &dc );    // <-- REMOVE
> > THIS!  Windows calls OnEraseBkgnd() for you
> >                                    ReleaseDC(&dc);        / /    <--
> > REMOVE THIS!  dc is automatically released in ~CPaintDC!
> >                        }
> >            }catch(...)
> >            {
> >                [...]
> >            }
> >
> > //          TRACE_EXIT;
> > }
> >
> >
>
>
> 2) Your OnEraseBkgnd() should paint the gifImageSet, not call the ancestor
> class which doesn't paint any image!
> 
> 
> -- David

0
10/13/2006 6:31:24 AM
Reply:

Similar Artilces:

Dynamic Xml editor
Hi, I am writing a user control that will help a user that know (almost) nothing about Xml to build a Xml file based on a Xsd schema that is given to the user control. The idea is to have a treeview on the left and a property grid on the right. The treeview is loaded with the root elements from the schema. When the user right click on a node, a context menu allow him to add subnodes if schema allow it. This way, the user can create items, attributes, ... The property grid is filled by the user with data. At the end, the Xml file is generated and validated. My problem is about the design....

Help with columns #2
Hi How do I create a worksheet with just 3 columns (A, B, C...) rather than thousands (AA, BB, CC...)? Thanks! Hi - first there's a maximum of 256 columns :-) - You can only use these 3 columns (you can't delete the other columns) - if you like you can hide the other columns. Just select theses columns and goto 'Format - columns - Hide' -- Regards Frank Kabel Frankfurt, Germany Rich wrote: > Hi > > How do I create a worksheet with just 3 columns (A, B, C...) rather > than thousands (AA, BB, CC...)? > > Thanks! See one answer in m.p.e.newusers Please d...

Trouble with Tab Control
I have a form in which i have a tab on it. The problem is the tab appears white and I would like to show the background behind it. I saw in the properties there was a section to make it "transparent" or "normal" i've selected botha nd nothing changes. Any ideas on how to solve this. thanks On Jan 25, 9:32 am, tsla...@gmail.com wrote: > I have a form in which i have a tab on it. The problem is the tab > appears white and I would like to show the background behind it. I > saw in the properties there was a section to make it "transparent" or > ...

Recipient Policy help #2
Our default recipient policy is companyname.local. We have 10 other recipient policy’s for each site within our company – they all have separate smtp addresses. The postmaster uses the default recipient policy smtp address companyname.local to send out ndr’s etc. but the address companyname.local is not allowed out of our firewall and it wont be allowed. We can create a new address to add as the default recipient policy which is unique and is allowed through the firewall. Please let me know if this is ok and what I should look out for??? So I am a little confused about what you are as...

Help, I cannot Save!
I created a document and locked the worksheet to protect the formulars before creating a template for the document. But now when I open th document and insert a new sheet using the template I created, th document will refuse to save. Once I click on save, office assistant will say "doc not saved". Wha could I have done wrong? PLease help. computerfinema -- computerfinema ----------------------------------------------------------------------- computerfineman's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3716 View this thread: http://www.excelforum.c...

Transferring control of CClientDC to CDC
Hi, I have a class MSWinDisplayManager which I want to take a CClientDC device context so that it's member functions can perform drawing routines on it. I want the class to have it's own CClientDC member which all the methods have access to draw on. My constructor looks like this: MSWinDisplayManager::MSWinDisplayManager(CClientDC& win) { private_win.attach(win); } This is called by the user like: CClientDC dlg(this); MSWinDisplayManager wdm(dlg); then I want to do things like: wdm.drawCars(); The problem I have is that private_win isn't getting control of the device ...

I cannot get the pictures to show on screen in Publisher web previ
I have tried embedding and linked but nothing seems to work. Do I have to apply a master page? It is to be a one page web site. This is probably so basic but I am trying to teach myself how to use it. What do I have to do to have them show in preview and once uploaded? Thank you. Are you using FireFox to preview or IE? DavidF "rendul" <rendul@discussions.microsoft.com> wrote in message news:C9B0A640-6C87-4E9A-8A0E-5F32F7DAC0DE@microsoft.com... >I have tried embedding and linked but nothing seems to work. Do I have to > apply a master page? It is to be a one ...

How disable postmaster reply in exchange 5.5
I receive mail from virus in my Exchange 5.5 with this format name@mydomain with a virus attached My exchange server reply with postmaster with the original mail attached. I think that this is Mydoom virus. Please help me to disable NDR messages for any e-mail sent to an invalid address. Virus send e-mail with field FROM with addres that want attack and my exchange reply with postmaster with the original mail that contain mydoom virus. Excuse me for my bad english. It is not possible to disable generation of NDR with E55. Why not install antivirus for Exchange? ALEX wrote: > I rece...

Macro Help 11-24-09
I have one workbook of data (1 tab) that has data for 20 different Sales Reps (different names). I need to copy all data for "Rep A" into a separate worksheet, and same for "Rep B" and so on. At the end I would have 1 tab for all data and 20 tabs with the data for each rep. Basically, I need to copy and paste each rep data into a new worksheet within the same workbook but didn't want to do it manually. I hope this makes sense. See Ron de Bruin's site for code. http://www.rondebruin.nl/copy5.htm Also check out his easyfilter add-in. http://www.ro...

Help Required
Hi, Whenever I open Outlook 2003, I am getting a dialog box which displays the following message: Microsoft Office Outlook has encountered a problem and needs to close. We are sorry for the inconvenience When I click Debug it displays a message box with the following error message "The instruction at "0x3007e993" referenced memory at "0x0000000:. The memory could not be read" When I click No it Visual Studio JIT debugger pops up. I uninstalled and installed several times but still the problem persists. Is there any regsitry entry that I've to modify/delete? ...

Excel 97 VBA Help File
In the MS Excel Visual Basic Reference help file contents page, I click on Functions and it only offers me functions beginning with the letter S. So, I have a list of Solver and SQL functions. But what about all the other functions in VBA, for example for doing arithmetic and manipulating dates and strings? Why don't they show up? Are they left out because those functions are all part of Visual Basic generally, and the Excel VBA help file is specific to the _extra_ functions in Excel VBA? It's the only explanation I can think of. Am I right, or have I got a corrupted help file (vbaxl...

HELP Recovering addresses and email from Outlook 2003
I had some serious driver issues that required re-installing XP from disc. I did use the backup option and have a backup of all the old data. And of course had to reinstall Office 2003. Will third party software restore my old email and addresses or am I out of luck?? Thanks for the help texraid wrote: > I had some serious driver issues that required re-installing XP from > disc. I did use the backup option and have a backup of all the old > data. And of course had to reinstall Office 2003. > > Will third party software restore my old email and addresses or am I > out of lu...

Need Help with Deleting Empty Paragraphs in Word 2003
I have written the code below to delete all empty paragraphs at the end of a document and then place the cursor at the end of the last paragraph. It works fine as a stand alone sub in a new doc, but fails inside the real document that contains other code that manipulates several documents. The failure is that it will delete the last empty para, but then gets stuck looping inside the While...Wend because subsequent .Delete are not happening. So, the question is why would this work in one document, but then fail in another? n = 0 ...

help need with VC 6.0 IDE and mfc
Hello, First let me explain the scenario where i m using this requirement. We are Using CustomAppWizard and designing a wizard .One of the wizard pages will Insert Composite controls as many as the user wants . 1.So i should be able to dynamically insert ATL controls without using Insert Control Dailog. 2. can any one tell me how to dynamically create Template file in TEMPLATE folder of resource view . 3. I want to include many files created by templet files and add them to build by editing newproj.inf Is it possible to do this. 4.I would even like to know if i have 2 ifles in my C drive h...

Timesheet to monitor flexi-time
Hi All, Does anyone have a spreadsheet that can be used to record employee timesheet details, capable of accommodating simple flexi-time and part time hours. Ideally, i would like an option to add employees and then enter their agreed working hours (this is to be used as a look up). Then, On a weekly basis, data will be entered for the previous 7 days� Hours worked can fall under the following categories... Hours worked �normal� time Hours worked flexi time Hours �Sick� Holiday Bank Holiday Authorised Absence Paid Authorised absence unpaid I'd also like A way of viewing information...

Getting the BCC field by default.
I would like the BCC field to show by default but cannot find the setting for this in 2007. Anyone know where this is located? In a new message window, use the Options chunk to display the "Show BCC." --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted without reading. After furious head scratching, JC HARRIS asked: | I would like the BCC field to show by default but cannot find the | setting for this in 2007. Anyone know where this is located? Thanks Milly. I had...

Help me identify my missing permission (Cannot open public folder) -2147217843 (Maybe Authentication Fails?)
The following snippet of code throws an error number -2147217843. When I googled this error code, I see many references to authentication failed. I am assuming my problem is some kind of permission related problem on the "MyNewFolder" public folder. -- start code --- Dim objFolder As New CDO.Folder Dim f As ADODB.Field 'sURL is like: file://./backofficestorage/mydomain.com/Public Folders/MyNewFolder/ objFolder.DataSource.Open sURL, , adModeReadWrite, adFailIfNotExists --- end code -- I have code that runs before this that actually creates the "MyNewFolder" publ...

Need HELP! for Linking data
Could someone please direct me to where I can learn how to link date in a work book. i.e., I have individual pages for each subject but I need the data that is entered in these individual pages to transfer to the Master page without having to manually in put it.........TNX Bubey, There are not too many bits about linking worksheets or workbooks that I can find. But have a look at the links below, in case they give you the information you need. I think it is frustratingly one of those things which is very easy when you know how, or if you can get someone to actually show you, but if you hav...

question about Time
How to make the time result for example if it�s ( 1:01 ) or higher shows only as ( 1:00 ) and if it�s Lower like ( 0:59 ) or less it will show the same result in this case ( 0:59 ) Any idea & suggestions. Thanks, almufadda@hotmail.com ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ Using Ron deBruin's google addin and asking for subject round time, I get http://tinyurl.com/wgua -- Don Guillett SalesAid Software donaldb@281.com "saud" <saud.xgc4...

Time Clock Systems
Does anyone have a recommendation for a time clock system that integrates well with GP? On Oct 5, 10:20 am, kcd <k...@discussions.microsoft.com> wrote: > Does anyone have a recommendation for a time clock system that integrates > well with GP? We just implemented Time Matrix by Business Computers (www.business- computers.com) and are very happy with it. We implemented quickly the hardware wasn't propietary or complicated so we were able to source our own stuff. Troy I can speak highly of Unitime's time and attendance system. They are a relatively low cost solution t...

How do I bind a XAML text box control to a dataset?
Hello; I am new to using WinFx and I am having trouble figuring out how to bind a text box to a field in a dataset. I found an MSDN article: http://msdn2.microsoft.com/en-us/library/ms752057.aspx My question deals with the text box code: <TextBlock Text="{Binding Path=ISBN}" Grid.Column="1" /> How does this text box know to bind to the field "ISBN" in "myDataSet"? How does the control implement the dataset? Thank you Monty ...

Controlling NDR's sent to Originator
Hi, I have a scenario: An Exchange2k User sets up an Auto Forward Rule to forward all inbound mail to a personal email account. This person recieves email into his Inbox and the Rule fires off forwarding the email to their personal account. His personal account is not reachable and Exchange sends a NDR to the original sender. Example: Step 1: john23@example.com sends email to corpuser7@corp14.com Step 2: corpuser7@corp14.com has an Inbox rule that forwards this email to his personal account at homeacct@isporg.com Step 3: exchangeserver.corp14.com recieves an NDR from pubmailer.isporg.c...

Getting rid of selection
How can I get rid of the selection rectangle? It seems that it's always there, with a heavy black rectangle, or there's a light black rectangle marking where it was. I'm trying to get rid of it altogether, so I can capture an image of the sheet for use in a webpage. I can achieve the effect that I want by selecting a cell which is outside the area that I'm trying to capture, but now that I've found that I cannot get rid of it entirely, it is driving me nuts trying to do so. -- Steve Swift http://www.swiftys.org.uk/swifty.html http://www.ringers.org.uk You could al...

Workplace Queues
We just rolled out CRM a few weeks ago. I'm getting a lot of complaints from the users about the thousands of items showing up in their My Work\Queues\In Progress folder. When I look at my own items, I have about 1000 activities showing in my In Progress folder but when I open them up most of them are owned by someone else. According to the Help description of this folder, only items that I have accepted should show up in my In Progress folder. I've never accepted anything, so I'm not sure anything whatsoever would be showing up in this folder. We used Scribe to import ...

Help with Registration
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hi, I've tried to register my copy of Office for Mac through the Mactopia page. I log in successfully, but then it just keeps on loading and doesn't refresh or change. Any advice? On 6/16/09 6:35 PM, in article 59b76b64.-1@webcrossing.caR9absDaxw, "theconfuzed1@officeformac.com" <theconfuzed1@officeformac.com> wrote: > I've tried to register my copy of Office for Mac through the Mactopia page. I > log in successfully, but then it just keeps on loading and doesn't refresh or > ...