Access violation problem

hi frds
  i want to resize my editbox at run time .but at line no 6 it is not
returning the control pointer
     and run time it is giving access violation ...
 plz see my code where i have done mistake ..
   i will appreciate

void CCFileDemoDlg::OnSize(UINT nType, int cx, int cy)
{




	1CDialog::OnSize(nType, cx, cy);
       2HWND* HWnd;
	// TODO: Add your message handler code here
	3 CRect l_formRect;
	  GetClientRect(&l_formRect);
	   CEdit *pEditCtrl;
	    6 pEditCtrl=(CEdit*)GetDlgItem(IDC_EDIT2);
            GetDlgItem(IDC_EDIT2);
	    long newWidthEdit = l_formRect.Width()/4;
		 if(newWidthEdit > 50)
      newWidthEdit = 100;

   long newWidthTab = l_formRect.Width() - newWidthEdit ;
    long newHeightEdit = l_formRect.Height();
	pEditCtrl->MoveWindow(l_formRect.TopLeft().x+2,l_formRect.TopLeft().y+10,(long)newWidthEdit,(long)newHeightEdit-5,TRUE);
	int i=GetLastError();
	pEditCtrl->RedrawWindow();

	
}

0
12/27/2006 1:04:50 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
529 Views

Similar Articles

[PageSpeed] 53

nandan.mehra@gmail.com wrote:
> hi frds
>   i want to resize my editbox at run time .but at line no 6 it is not
> returning the control pointer
>      and run time it is giving access violation ...
>  plz see my code where i have done mistake ..
>    i will appreciate

OnSize can be called before the dialog's controls have been created.  So 
you must make sure the control exists before accessing it:

  pEditCtrl=(CEdit*)GetDlgItem(IDC_EDIT2);
  if (pEditCtrl && pEditCtrl->GetSafeHwnd())
  {  pEditCtrl->MoveWindow(...);
  }

-- 
Scott McPhillips [VC++ MVP]

0
Scott
12/27/2006 1:48:08 PM
In addition, why are you using GetDlgItem at all?  If you're writing more than one
GetDlgItem per year, you probably aren't using MFC correctly.  See my essay on avoiding
GetDlgItem; create a member variable.  You still have to make sure the control is defined,
e.g.,

	if(c_MyEdtCtrl.GetSafeHwnd() != NULL)
		...resize

				joe

On Wed, 27 Dec 2006 08:48:08 -0500, "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
wrote:

>nandan.mehra@gmail.com wrote:
>> hi frds
>>   i want to resize my editbox at run time .but at line no 6 it is not
>> returning the control pointer
>>      and run time it is giving access violation ...
>>  plz see my code where i have done mistake ..
>>    i will appreciate
>
>OnSize can be called before the dialog's controls have been created.  So 
>you must make sure the control exists before accessing it:
>
>  pEditCtrl=(CEdit*)GetDlgItem(IDC_EDIT2);
>  if (pEditCtrl && pEditCtrl->GetSafeHwnd())
>  {  pEditCtrl->MoveWindow(...);
>  }
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/27/2006 2:28:37 PM
Reply:

Similar Artilces:

Restricting access to note attachments
Hi all, is there a way to restrict access to attachments on notes to specified users. I know we can, using the Security Roles, define who can and can't read/ write the notes fields but we would like our users to be able to view the note, but not open the attachment(s) unless they are the owner of that note (or at least in the business unit, etc.). I know this could be done for Word/ Excel files in Office (Password protection) but are looking for something more encompassing for all attachments inside CRM. Thanks, -- Matt Pring On Oct 21, 3:54=A0pm, Matt Pring <MattPr...@discus...

Outlook Web Access AutoSignature
I would like to know if it's possible to have autosignature in Outlook Web Access, and if so how to implement it. If anyone can help, it would be greatly apreciated. Thank You. It depends on the version of Exchange - Outlook Web Access is a function of Exchange, not Outlook. Exchange 2003 does this natively, previous versions may have a third party add-in that will allow users to do this. For better information, post in an exchange group such as microsoft.public.exchange.admin. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due t...

Having problem Installing Exchange Router
When Installing I keep getting this error: Setup was unable to install the Microsoft CRM-Exchange E-Mail Router. This installation is forbidden by system policy. Contact your system administrator (80070659) I log on as adiminstrator account with local and domain access. I have tried reinstalling Windows installer and Script Host. Please help Make sure the user you are using to install is the same CRM admin user name you used to Install the MS CRM. I hope this works. "Thomas" wrote: > When Installing I keep getting this error: > Setup was unable to install the Mic...

Access 2003 and Access 2007 Synchronization
I'm setting up a new business relationship with a company in Portugal. They use Access 2003. I have just bought MS Office Professional 2007 (with Access 2007). Our plan is that they will send, once a month or so, their Access db then we will update and add to that db and then return it after another month or so. There probably won't be a lot of updates on our end so the monthly cycle should work. After they synchronize, they will send a new version of the db and we will start over. My goal is to keep everything as simple as possible partially because I don't know how skillf...

XPath problem with two xmlns
I have got file raport.rld which is an XML file generated by MS Reporting Services. The problem is: in this file are tags from two different namespaces xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini tion" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" when I'm trying to use XPATH to get <teble> tag it doesn't work. (the result is empty) I've removed All tegs like <rd:TypeName>System.Int32</rd:TypeName> Now all is working fine but what to do when I have tags from two different...

Help displaying a random record in a form--Access newbie
Hello, I am new to Access, so if anyone can help me, please assume I know absolutely nothing! I currently have a table with two columns, ID and CHORE. In each row, the ID number corresponds to a chore that I have entered. I would like to create a form with a button and a text field such that when I press the button, a random chore is displayed in the text field (supposed to make chores more "fun" for my son). There is no need to remove this record from future clicks (the same record can come up over and over without any problem for me) Can anyone explain to me (in pai...

Outlook Express(6.0) INBOX Problem
I have a problem with M.S Outlook Express where I appear to have ten messages permanantly stuck in my INBOX.No matter how many times I try to access them or do a send/receive they remain "stuck" in there.I think this may have something to do with my McAfee Internet suite(8.0) which I have just had to reinstall.I have tried disabling all elements of Mcafee in case one of these is inhibiting the "release of my O.E INBOX , but still no joy.Do I have to reinstall Outlook EXpress and if so will I lose all my e mails etc.I can in the mean time send and receive E mails as per normal a...

Excel Row to Access Columns
Hi, I have a single row in Excel with a lot of data, what I need to do is move that to a column in Access. I need some way to automate that. I know the easiest way to do that would to just transpose it in excel and then import in access.But I cant do that as I just get that excel file with one row and I need some way to automate the process in Access. thanks m -- mk389 ------------------------------------------------------------------------ mk389's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15272 View this thread: http://www.excelforum.com/showthread.php?...

Outbox Problems
I cannot send any emails on Outlook because they get stuck in the Outbox. While they are stuck in my outbox the most unusual thing happens: the intended recipient of the email gets multiple (sometimes as many as 40-50 of the email in their Inbox and they call me and tell me to stop whatever it is that I am doing because it is "out of control". Help. What version of Outlook are you using? Also, do you receive any error messages when trying to send mail items? "Delores" <Delores@discussions.microsoft.com> wrote in message news:F0BD4903-3F93-4656-8416-879B5B74...

Access
Hi My form takes a few moments to load up as it is fairly substantial SQL statement is there a way to get something to display a graphic or 'loading...' message to appear why it calculate the contents? Steve ...

access mail on WEB
Is there a way i can check emails from exchanger server 5.5 from an internet browser. I have Exchange 5.5 in win NT 4.0. Thanks! Yes - install OWA (Outlook Web Access) and open up the needed ports in your firewall (80 for http; better to use SSL and port 443 instead). disk0nek wrote: > Is there a way i can check emails from exchanger server > 5.5 from an internet browser. > > I have Exchange 5.5 in win NT 4.0. > > Thanks! ...

Logic Problem
I have a problem that has taken me many attempt to solve, all fruitless. I have a long list of data and want to insert a reason code based on some criteria. In colounm Q there have been reasons imputed by others. In colounm R2 i would liek a astatement to say "if the value of p2 is between -.04 and . 04and Q2 is blank, return the value 13, otherwise return what is in Q2. but if colounm C2 is blank or has the letters "HPC" i also want to return a 13. PLease help me on this thanks alot -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/ms-excel/20...

Money 2003 password problems
Hi, I run Windows XP and Money 2003. I recently moved all my "c:\documents and settings" to another drive, which involved me having to make registry changes so windows knew where the "My documents" and "Shared Documents" had moved to. Everything worked fine, although I had some problems with MS money after the move so I uninstalled it and reinstalled it again (the exact same version). Since I have reinstalled it, the password I used to use to open my money file is not recognised. I am 100% certain that I am using the correct password. I tried using salv.exe to...

access or mount mirrored hard disks
Hi, is it possible to access a mirrored harddrive? or mount the mirrored volume by using api or mfc commands? Thank you in advance Wimpi ...

CRM v4 Accessibility Improvements
Hi all: Does anyone know if any improvements have been med to CRM v4 in the area of accessibility for handicapped users? One of my customers has a user who is blind and they need to make the software accessible to him. Thanks in advance for any and all help. John. Hi John, We have added following Accessibility features in CRM 4.0 : 1) High Contrast Mode (Tools --> Options --> General Tab --> Enable high contrast settings) 2) All the Form input elements have <LABEL FOR> to aid in screen readers. 3) All the Images have a ALT tag (for non text elements) etc. Thanks! Ma...

Access Database In Great Plains
I was wondering if anyone knew how to have the databases that are stored in access transfered over to great plains. I'm current running version 8.0 any help would be greatful. thanks Search Customer Source for integration Manager. MS Access databases can be used as a data source. Vincev "jake" wrote: > I was wondering if anyone knew how to have the databases that are > stored in access transfered over to great plains. I'm current running > version 8.0 any help would be greatful. thanks > > Hi Jake, Is this something you need to do regularly or is it ...

Upsizing Access to SQL Server 2000
Hello, I am new to SQL Server. I am trying to use the Database upsizing wizard to upsize a Access 2000 database into SQL Server 2000. They are both on the same machine (running Win 03 Server). I cannot connect to the SQL Server. Error as below: Connection failed: SQLState: '01000' SQL Server Error: 14 [Microsoft][ODBC SQL Server Driver][Shared Memory] ConnectionOpen(Invalid Instance()). SQLState: '08001' SQL Server Error: 14 [Microsoft][ODBC SQL Server Driver][Shared Memory]Invalid connection. ...

Outlook Web Access #19
We have have OWA at my work and I would like to configure Outlook 2003 to synchronize with my desktop at work, is this possible Thanks B ...

Have a user account accessible to multiple users
I have an issue where there is a user account that has multiple alias emails.(reservations@domain.com, info@domain.com, CustomerService@domain.com) I have an exchange 2003 server. My issue is that i need to have muliple users access these emails so they are never missed. What is the best way to accomplish this? I was thinking a public folder. But i want to know the best way to do this? On Sat, 12 Jun 2010 21:37:04 -0500, "Dan V" <dvalenti54athotmail.com> wrote: >I have an issue where there is a user account that has multiple alias >emails.(reservati...

Going offline without write access to registry
I suggest that POS doesn't go offline if it can't write into registry, displaying a message box instead telling that it couldn't access the registry. What happens if the POS machine goes offline without having access to edit the registry? This typically happen when the user is a normal user (not a power user) 1. The POS application will try to connect to the server main database within the pre-configured ‘Connect Timeout’ in the RMS Administrator (Typically 15 seconds) 2. The application will then try to connect to the pre-defined offline database (which is usually stored loc...

Problem with Categoruies
Hi Everyone, I had to reformat my laptop HD a few days ago. Once I reinstalled MS Outlook 2003 I restored a backup of my Personal Folder. Problem: Contacts have Categories that are not listed in the Master Category list. How can I update the Master Category List to reflect the Categories from my contacts and be able to use these same categories for other contacts. I know I can do this manually but was wondering if there is a faster way. Thanks in advance for any help your can provide. ================== Sheila No, there's no faster way. The master category list is held in the ...

Problem displaying a form that runs queries
Hello, In Access 2007, I’m having a little issue displaying a form that runs queries on load. Below is my code. When I double click the form, the queries begin to run but the form only appears after the queries are done. If I put the code behind a command button it works fine. I can’t use a command button because I need the queries to run unattended when the DB opens. Where am I going wrong? Private Sub Form_Open(Cancel As Integer) DoCmd.MoveSize 2880, 4320 End Sub Private Sub Form_Load() DoCmd.SetWarnings False '********************************** 'QUERIES ...

Access 2000 problem if opened with Access 2007
Dear all, I'm running Access 2000 MDE in Access 2007. I find several header-details form (such as invoice transaction), the details form is displayed as white box without any record displayed. Is there any solution for this matter ? Thanks. Chlaris. you need to move to Access Data Projects if you want a reliable, predictable environment "Chlaris" <chlarrissa_nospam@yahoo.com> wrote in message news:ON0rS1NsHHA.3884@TK2MSFTNGP04.phx.gbl... > Dear all, > > I'm running Access 2000 MDE in Access 2007. I find several header-details > form (such as inv...

Printing problems
My computer is running Windows XP with 384MB of RAM, and I am using Publisher 2000. I am printing to a HP color laserjet 5 which HP does not offer any drivers on thier site for this printer and Win XP. The HP driver site for this printer says that the driver was included into Windows XP. The printer is connected using the parallel port. I have cropped a picture of a group of teens and made three pictures out of the one and added some text to create a publicity flier. I accomplish this by inserting the picture and then making 2 copies of it and then I crop each one to make 3 dif...

Accounting with Ms Access
Hello all I have been working on a database for are small retail Tile company (we do everything by pen and paper now). I have been able to setup a working Orders/Invoice table and forms, CreditMemo table and forms, and PurchaseOrder table and forms all based on the Northwind Sample Database. "Thanks to all the help here". I have been searching for a sample database with accounting. With A/R, A/P, Billing Statements and so on. I am not a programmer or accountant so the chance of me doing something wrong is pretty good. I am hoping that someone has a add-in MsAccess database for ...