|
Hi Dear...
I'm trying to bind DB-Grid & ADO..please help Me..
I'm using MS-DB Grid Control & MS ADO Control ActiveX.using vc+6.0. I want to bind ADO & Grid
Thanks for help Advance..
what I'm Doing is:
int CDBGridTestDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
m_Ado.Create (NULL,WS_VISIBLE|WS_CHILD,CRect(0,0,100,20),this,IDC_ADODC1);
m_Ado.SetConnectionString("Provider=MSDASQL.1;Persist Security Info=False;Data Source=FileCheck");
//m_Ado.SetCommandType(2);
m_Ado.SetRecordSource("Select * From TBL_ITEM_TYPE");
m_Ado.Refresh();
m_Grid.Create(NULL,WS_VISIBLE|WS_CHILD,CRect(20,20,300,200),this,IDC_DBGRID1);
LPUNKNOWN pCursor=m_Ado.GetDSCCursor();
m_Grid.SetDataSource(pCursor);
m_Grid.BindProperty(0x9, &m_Ado);
m_Grid.Refresh();
return 0;
}
bye
---Sumit Kapoor---
|
|
|
|
|
Hi
As usual i recd. following message on my build output window
How to find the point of the memory leak and how to overcome it.
Thanks a lot for any suggestion.
Sandeep
Detected memory leaks! <br />
Dumping objects -><br />
strcore.cpp(118) : {1639} normal block at 0x0063B6B0, 181 bytes long.<br />
Data: < ODBC> 01 00 00 00 A8 00 00 00 A8 00 00 00 4F 44 42 43 <br />
D:\Documents and Settings\erc\Desktop\Pattern\DBManager.cpp(32) : {1633} client block at 0x0063B900, subtype 0, 100 bytes long.<br />
a CDatabase object at $0063B900, 100 bytes long<br />
D:\Documents and Settings\erc\Desktop\Pattern\PatternDoc.cpp(508) : {1535} client block at 0x0063A180, subtype 0, 88 bytes long.<br />
a CObject object at $0063A180, 88 bytes long
Leave your mark wherever you go
|
|
|
|
|
You usually find the memory leak by simply clicking on the line reported say
strcore.cpp(118)
But, if that file resides out side your project, as strcore.cpp does (its part of MFC) it wont work.
The second leak should "D:\Documents and Settings\erc\Desktop\Pattern\DBManager.cpp(32) "
Double click it and it will take you to where it was allocated.
As for the first, you have a leak via a CString somewhere.
|
|
|
|
|
ah you beat me to it... gotta type a little faster next time
|
|
|
|
|
Well they gets two answers to their Q not just one - effeciant this CP message board eh.
|
|
|
|
|
one way is dubble clicking on the line
the other reading it..
first line says:
strcore.cpp(118) etc etc etc
says that the mem was allocated on line 118 of the strcore.cpp file...(but never deallocated)
in your DBManager.cpp file line 32 you allocate memory that wasn^t deallocated
same for PatternDoc.cpp line 508.
as for in which situations that occurs... Debug!! put breakpoints and read carefull your new and delete statements!
Regards,
Davy
|
|
|
|
|
Thanks i will check it and will come up back
Leave your mark wherever you go
|
|
|
|
|
Hi,
this is my problem.
I have an MFC diaog based application with multiple edit boxes.
What I need to do is to automatically select all the text inside a box when clicking on it.
That's just what happens on Explorer address bar...
I've tried writing inside each OnSetfocusEdit function
m_edit.SetSel(0,-1);
m_edit.SetFocus();
I also tried to write only the line
m_edit.SetSel(0,-1);
but it didn't work.
If I put the same 2 lines in a button click the operation succeeds.
Why is this?
Can anyone help me?
Thank you in advance,
Marco.
|
|
|
|
|
the SetFocus call is not necessary anymore in the OnSetFocus.. functions, since it allready is getting the focus.
That`s probably the source of all evil...
Regards,
Davy
|
|
|
|
|
Already done, but it doesn't work...
Any other suggestion?
Thanks,
Marco.
|
|
|
|
|
Hi Marco,
Try the PreTranslateMessage override, e.g. for an IE address bar type behaviour...
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
BOOL bEatMe = FALSE;
if (pMsg && pMsg->message == WM_LBUTTONDOWN)
{
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
if (pEdit && pEdit->GetSafeHwnd() && pMsg->hwnd == pEdit->GetSafeHwnd())
{
CWnd* pPrevFocus = pEdit->SetFocus();
if (pPrevFocus == pEdit)
{
}
else
{
bEatMe = TRUE;
pEdit->SetSel(0,-1, TRUE);
}
}
}
return (bEatMe) ? TRUE:CDialog::PreTranslateMessage(pMsg);
}
Hope this helps,
Andy
|
|
|
|
|
;););););););););););););););)
Thanks a lot !!!!!! Now it WORKS !!!!!!
Marco.
;););););););););););););););)
|
|
|
|
|
If the clicking of an edit control selects all of the text contained within it, how is a person able to make a correction? Normally, a double-click of an edit control selects all of the text contained within it, and a single-click merely places the edit cursor at some point within the control. Doesn't this sound counterintuitive?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I think you'd want this behavior only if the user is likely to almost always replace the existing text. The user can still modify the text by pressing "End", "Home" or the arrow keys to first clear the selection, although this involves an extra keystroke.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I hv Integer Value which i need to convert as POSITION to assign starting POSITION for the collection class.
CTypedPtrMap m_Contacts;
POSITION pos;
CString strKey;
CContact* pContact; // Collection class which reads information from local file
int iIndex = m_screenName.GetCurSel(); // gets cursor position from combo
Now i need to assign the cursor position as POSITION for CTypedPtrMap.
m_Contacts.GetNextAssoc(pos, strKey, pContact);
Please inform me how to solve this?
|
|
|
|
|
Is the screen name the key into the contacts map? If it is, you can get that using m_screenName.GetLBText . If not, you could associate the key with the item in the combo using m_screenName.SetItemData .
I assume you have a good reason for using a Map, otherwise I would suggest using a List or an Array. MFC's map classes are based on a hash-table, which means that you won't get elements out of them in the order you inserted them, or in any predictable order, so you can't just call GetStartPosition then call GetNextAssoc repeatedly.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
A POSITION is like an iterator for a collection - its not synomous with an integer.
The CTypedPtrMap will be keyed by what ever you templateized it on - looking at this a string.
So you can find your CContact based on a CSring easily, which is the key into the map.
How did you insert into the map?
Did you insert all the keys into m_screenName, then insert each CContact into the map based on the key?
If so, you can do a GetText on the combo to get the text for item iIndex, then use that look up in the map.
CString str;
str = m_screenName.GetText(iIndex);
CContact* p = NULL;
BOOL b = m_Contacts.Lookup(str, p);
etc
If not, the only thing u can do is to advance around the map until u hit the position at iIndex:
POSTION pos = m_Contacts.GetStartPosition();
int nElement = 0;
while(pos != NULL && nElement++ <= iIndex)
{
pos = m_Contacts.GetNextAssoc(pos, strKey, pContact);
}
You get the idea - iterate around the map until you get to element iIndex.
|
|
|
|
|
Hi,
In my application i created 2 Threads.From the T1(first thread) i create the T2(second thread).While the T2 is executed,i need the T1 to pause and block all
IO operations completely like getting and writing data from named pipes and sockets.
Pls do help how to achieve this.I'm strugling.I used flags to block IO but that doesn't seems to block completely.
Pls help.Thanks in advance
ram
|
|
|
|
|
Create an event and use WaitForSingleObject
then signal the event from thread 2 whenever you want thread 1 to go on
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for the reply.
Problem here is,in second thread ,only on a particular condition i need to block th e user input.the second thread should run as background process without interrupting the
first thread.
I need to block all IO operations.I'm using named pipes and overlapped IO.
in this case how to block IO.even though i set flags,after finishing the second thread,
all pending IO gets excuted.How to avoid this.Pls help
Can i use CancelIO?
Thnks
ram
|
|
|
|
|
Use the HANDLE of the second thread as the Kernel object in WaitForSingleObject() in the first thread.
HANDLE hThread2 = CreateThread(...);<br />
WaitForSingleObject( hThread2, INFINITE);
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Thanks for the reply.
Problem here is,in second thread ,only on a particular condition i need to block th e user input.the second thread should run as background process without interrupting the
first thread.
I need to block all IO operations.I'm using named pipes and overlapped IO.
in this case how to block IO.even though i set flags,after finishing the second thread,
all pending IO gets excuted.How to avoid this.Pls help
Can i use CancelIO?
Thnks
ram
|
|
|
|
|
i wana create the window but there is some problem can any one slove it
#include<afxwin.h>
#include"resource.h"
class Dialog:public CDialog
{
public:
Dialog(int n = IDD_FORMVIEW):CDialog(n)
{
}
};
class MyDialog:public CDialog
{
public:
MyDialog(int n = IDD_DIALOG1):CDialog(n)
{
}
void OnOK()
{
CWnd *p;
p = new CWnd;
MyDialog gh;
int i;
CString str;
GetDlgItemText(IDC_EDIT_PASSWORD,str);
if(str == "arif")
{
MessageBox("Welcome","Conregulation");
p->Create(0, "Hi", WS_CHILD | WS_VISIBLE,
CRect(0, 0, 20, 20), NULL, NULL,NULL);
p->ShowWindow(1);
}
else
PostQuitMessage(0);
}
void OnCancel()
{
//Create(NULL,"Hello",WS_OVERLAPPEDWINDOW,CRect(20,20,200,200),NULL);
}
};
class CPassword:public CFrameWnd
{
private:CEdit *ed;
CString str;
public:
CPassword()
{
MyDialog dlg;
LoadAccelTable(MAKEINTRESOURCE(IDR_ACCELERATOR1));
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CPassword,CFrameWnd)
END_MESSAGE_MAP()
class CPasswordApp:public CWinApp
{
public:
int InitInstance()
{ MyDialog dlg;
CString str;
MyDialog *p;
p = new MyDialog;
p->Create(IDD_DIALOG1,NULL);
p->GetDlgItemText(IDC_EDIT_PASSWORD,str);
p->ShowWindow(1);
m_pMainWnd = p;
return 1;
}
};
CPasswordApp a;
|
|
|
|
|
Yes....
Get youself a good MFC book and go from there...
|
|
|
|
|
Anonymous wrote:
i wana create the window but there is some problem...
And that problem would be? Please be more specific with your request. You'll get way more help that way. Unless there is money involved, no one likes having code dumped in front of them with a note saying "There is some problem. Can any one solve it?"
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|