|
Hi,
I have to pass a BSTR string which is read from a xml file(using simple C-style fopen,fgetws methods) to a COM method. Within the COM method this BSTR string is to be passed further to a method that takes _bstr_t as a parameter. The problem arises when the BSTR string is to be passed further to the method contained within the COM method. The conversion from BSTR to _bstr_t converts only a portion of the string and not the complete string.
Since _bstr_t is just a wrapper over BSTR, it must take BSTR and form a object of _bstr_t,but the object is not showing the complete string passed to it. How do I solve this problem??
Thanks and Regards,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Try using the BSTR in the _bstr_t's constructor, e.g. _bstr_t stuff(/*BSTR here*/);
This should solve your problem
When I was young my mother told me to clean up my room, I told her -1!
|
|
|
|
|
In MFC, I want to pass an IP ADDRESS to the next dialog. But there are some problems. I am creating a variable (CString ipad) in CProjDoc then
DWORD m_ipsource;
CView* v;
CProj1Doc* pd=GetDocument();
ASSERT_VALID(pd);
m_add.GetAddress(m_ipsource ) ;
pd->ipad=m_ipsource;
class2 c2;
CDialog::OnOK();
c2.DoModal();
Plz help me out or tell me a better way of doing so.
Reply me soon
|
|
|
|
|
Use a private member within your CProj1Doc class for your CString ipad variable, and implement a getter and setter method for it; then you can access the member within your class2 like this: m_newcstring = pd->Getipad();
When I was young my mother told me to clean up my room, I told her -1!
|
|
|
|
|
Hi All,
First Off, I've been reading the articles here for a while, but have never ventured as far as making a post. So I should say thanx to all for some exceedingly good articles, they have helped me a lot.
Now the fawning is out of the way .. My Question....
I'm building from the command line using .NET with a batch file.
"C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe" "d:\Dev\proj\proj.sln" /build "All Debug" /out "d:\Dev\proj\proj.txt"<br />
type "d:\Dev\proj\proj.txt"
Unfortunaly this does not allow me to see the log file being generated until the build is finished, even various tail utils fail to open the file (I'm assuming due to the file being held open by .NET).
I'm sure VC6 outputted to stdout, but .NET does not, any ideas how I could get to see an output in progress?
Thanx
DAve
|
|
|
|
|
dear all,
i'm getting this exception while debugging in debug window :-
First-chance exception in Schd Tasks_D.exe: 0xC0000005: Access Violation.
when a function in my program returns FALSE.
but the programs runs successfully.
if the function returns true, i do not get this exception and program still runs successfully.
i don't know why
plz. help
regards
|
|
|
|
|
The Discription you gave is very Abstract.Generally "0xC0000005: Access Violation." error arises due to many reasons..one of that is invalid memory access or looking into other process's memory with having sufficient privileges.Give some more details..
|
|
|
|
|
following is the piece of code
(i check File Modification Time Of a File With Another Time which comes from an INI File and return TRUE / FALSE accordingly)
BOOL CreateTasks()
{
BOOL bret;
DWORD dwError;
CErrorLog oErr;
CConfig oConf;
CString sTCDate(oConf.GetTaskCreationStamp());
int len = sTCDate.GetLength();
if ( len = 12 )
{
SYSTEMTIME stTCStamp;
FILETIME ftTCStamp;
try
{
stTCStamp.wYear = (WORD)atol (sTCDate.Mid (0,4) );
stTCStamp.wMonth = (WORD)atol( sTCDate.Mid (4,2) );
stTCStamp.wDay = (WORD)atol(sTCDate.Mid (6,2) );
stTCStamp.wHour = (WORD)atol(sTCDate.Mid (8,2) );
stTCStamp.wMinute = (WORD)atol( sTCDate.Mid (10,2) );
stTCStamp.wSecond =0;
stTCStamp.wMilliseconds =0;
//stTCStamp.wDayOfWeek = 2;
//bret = SystemTimeToTzSpecificLocalTime(NULL, &stTCStamp, &stTCStamp);
bret = SystemTimeToFileTime(&stTCStamp , &ftTCStamp);
dwError = GetLastError();
FILETIME ftModTime;
CString filename = oConf.InputFilePath();
filename.ReleaseBuffer();
HANDLE hFile = CreateFile(filename,GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);
bret = GetFileTime(hFile,NULL,NULL, &ftModTime);
bret = FileTimeToSystemTime(&ftModTime , &stTCStamp);
bret = SystemTimeToTzSpecificLocalTime(NULL, &stTCStamp, &stTCStamp);
bret = CompareFileTime(&ftTCStamp, &ftModTime);
dwError = GetLastError();
CloseHandle(hFile);
}
catch(...)
{
oErr.LogErrors(-1, "Exception Occurred While Comparing Modification Time For Input File With Value In Config File. Deleting And Re-Creating Tasks.");
return false;
}
}
else
{
oErr.LogErrors(-1, "Invalid Value Specified For TimeStamp In Config File. Deleting And Re-Creating Tasks."); return FALSE;
}
if (bret < 0)
{
oErr.LogErrors(-1, "Input File Modified. Re-Creating Tasks.");
return FALSE;
}
else
{
oErr.LogErrors(-1, "\n\r\nInput File UnModified. Tasks Not Re-Created.\n\r\n*********************************************************\n\r\n");
return TRUE;
}
}
sorry for the indentation
but i get error where function returns TRUE (last 3rd line of the code)
i hope now u can help me out
regards
|
|
|
|
|
Hello,
I'm looking for the mean to open a dialog which let the user to select a directory. I want a similar dialog box than the one of Winzip when it ask the user to select the folder in a tree, to extract files.
Is there a class available in MFC?
Thanks
|
|
|
|
|
|
CString result;
TCHAR rootPath[MAX_PATH];
BROWSEINFO bi;
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
ZeroMemory(&bi,sizeof(bi));
bi.hwndOwner = NULL;
bi.pszDisplayName = 0;
bi.lpszTitle="Choose directory";
bi.pidlRoot = 0;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN;
pidl = SHBrowseForFolder(&bi);
if (pidl)
{
if (SHGetPathFromIDList(pidl,rootPath))
{
result=rootPath; }
pMalloc->Free(pidl);
pMalloc->Release();
}
}
and you have the path in variable result.
Adapted from Mike's FAQ. [^]
~RaGE();
|
|
|
|
|
Oh yes, thanks a lot every one.
|
|
|
|
|
Iam doing a MFC project .I need to launch the diaolog box which prompts the user to create the DSN ( which is normally done by manually clicking control panel->Administrative Tools->ODBC).
How do i launch the Dialog box which prompts the user to create a new USER DSN .
"Nothing worthwhile is ever achived without Deep thought and hardwork "-JRD Tata
|
|
|
|
|
From the top of my head there are a couple of ways to do it:
- SQLDriverConnect() in the ODBC API
- CDatabase::Open() / OpenEx()
It is probably possible to get it from other database APIs as well...
Hope it helps!
|
|
|
|
|
HJo,
CDatabase::Open gives an option to OPEN .But it also gives an option to SELECT the DSN too .WHat i require is the dialog box which prompts the user to ADD,Remove ,COnfigure DSNs.
ANyway ,thanks a lot for the suggestion
|
|
|
|
|
Check out the function named ConfigDSN
Regards,
BB
|
|
|
|
|
Hi I am looking to send my own udp packet
please anyone can help me wih code or website any helping material.
Reply me soon
|
|
|
|
|
What's wrong with send or sendto ?
Not that I see how this connects to VisualC++?
|
|
|
|
|
In VC++ , I have a dialog. This has some combo boxes. I am populating the data onto the combo box . When I run the application, if I select the item in the combo box using keyboard, it works once or twice. after that even if i type the first letter of an existing item, the cursor is not changed.
does anyone know
|
|
|
|
|
I've made my own check box and put it into my dialog, everything is fine, but when i call the DDX_Check, this return no value, i've used a BOOL option to set as true or false, when is checked or unchecked, but nothing happens, nothing is registered, my check box is a CButton derived class, what's wrong?
|
|
|
|
|
Have you called UpdateData? Maybe show some code so we can help you better.
Regards,
Alvaro
There are no stupid questions, but there are a lot of inquisitive idiots. -- despair.com
|
|
|
|
|
this is my code:
IMPLEMENT_DYNAMIC(CAUICheckBox, CButton)
CAUICheckBox::CAUICheckBox()
{
m_bCheckBtn=FALSE;
m_bPressBtn=FALSE;
m_bOldTemp=FALSE;
m_clrHigh=globalData.clrHilite;
m_clrCheck=RGB(0,0,0);//RGB(0,170,170);
m_bSelected=FALSE;
m_Checked = FALSE;
}
CAUICheckBox::~CAUICheckBox()
{
}
BEGIN_MESSAGE_MAP(CAUICheckBox, CButton)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_ERASEBKGND()
ON_WM_MOUSEMOVE()
ON_WM_MOUSEOUT()
ON_WM_KEYDOWN()
ON_MESSAGE(BM_SETCHECK, OnSetCheck)
ON_MESSAGE(BM_GETCHECK, OnGetCheck)
END_MESSAGE_MAP()
// CAUICheckBox message handlers
BOOL CAUICheckBox::OnEraseBkgnd(CDC *pDC)
{
return TRUE;
}
LRESULT CAUICheckBox::OnGetCheck(WPARAM wParam, LPARAM lParam)
{
return m_Checked;
} // End of OnGetCheck
void CAUICheckBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
CRect m_rcClient=lpDrawItemStruct->rcItem;
UINT m_State=lpDrawItemStruct->itemState;
CBrush cb;
CRect m_rcTemp=m_rcClient;
CPoint pt;
CSize m_Csize;
CString m_szCaption;
COLORREF m_Over=RGB(255,193,111);
CPen cpOver(PS_SOLID,1,RGB(255,193,111));
int iMode=pDC->SetBkMode(TRANSPARENT);
int iExtile=GetButtonStyle(); //obtenemos orientación del texto
CRect m_rcText=m_rcClient;
GetWindowText(m_szCaption);
if(m_szCaption.GetLength() > 1)
m_Csize= pDC->GetTextExtent(m_szCaption);
//de acuerdo a la alineación del texto prepare la ubicación
//del texto para Drawtex y DrawState
if (m_rcClient.Height() > 13)
{
int Dif=m_rcClient.Height()-13;
Dif/=2;
m_rcTemp.top=Dif;
m_rcTemp.bottom=m_rcTemp.top+13;
}
if (iExtile & BS_LEFTTEXT)
{
m_rcTemp.left= m_rcTemp.right-13;
pt=CPoint(m_rcTemp.left,m_rcTemp.top+1);
}
else
{
m_rcTemp.right= m_rcTemp.left+13;
pt=CPoint(m_rcTemp.right+2,m_rcTemp.top+1);
m_rcText.left=m_rcTemp.right+1;
}
//draw frame of checkbox
pDC->FillSolidRect(m_rcTemp,globalData.clrWindow);
pDC->Draw3dRect(m_rcTemp,globalData.clrBtnDkShadow,globalData.clrBtnHilite);//clrBtnLight);
m_rcTemp.DeflateRect(1,1);
pDC->Draw3dRect(m_rcTemp,globalData.clrBtnShadow,globalData.clrBtnFace);
//DrawOrange(pDC,m_rcTemp);
m_rcTemp.DeflateRect(1,1);
if (lpDrawItemStruct->itemState & ODS_DISABLED)
pDC->DrawState(pt, m_Csize, m_szCaption, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
else
{
pDC->DrawText(m_szCaption,m_rcText,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
if(lpDrawItemStruct->itemState & ODS_SELECTED||m_Checked)
{
if (m_bOldTemp == TRUE)
DrawCheck(pDC,m_rcTemp);
}
else
{
if (m_bCheckBtn==TRUE && m_bPressBtn==FALSE)
DrawCheck(pDC,m_rcTemp);
else
{
if (m_bOldTemp == TRUE && m_bPressBtn==TRUE)
DrawCheck(pDC,m_rcTemp);
}
}
}
}
void CAUICheckBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
SetCheck(m_Checked ? 0 : 1);
CButton::OnKeyDown(nChar, nRepCnt, nFlags);
}
LRESULT CAUICheckBox::OnSetCheck(WPARAM wParam, LPARAM lParam)
{
m_Checked=wParam!=0;
Invalidate();
return 0;
} // End of OnSetCheck
void CAUICheckBox::DrawCheck(CDC* pDC,CRect m_rcTemp)
{
int iMediaAltura=(m_rcTemp.Height()/2)-2;
int iMedioBox= m_rcTemp.Width()/2;
CPen cp(PS_SOLID,1,m_clrCheck);
CPen *pOld=pDC->SelectObject(&cp);
pDC->MoveTo(m_rcTemp.left+1,m_rcTemp.top+iMediaAltura+3);
pDC->LineTo(m_rcTemp.left+3,m_rcTemp.bottom-2);
pDC->MoveTo(m_rcTemp.left+3,m_rcTemp.bottom-2);
pDC->LineTo(m_rcTemp.right-1,m_rcTemp.top+2);
pDC->MoveTo(m_rcTemp.left+1,m_rcTemp.top+iMediaAltura+2);
pDC->LineTo(m_rcTemp.left+3,m_rcTemp.bottom-3);
pDC->MoveTo(m_rcTemp.left+3,m_rcTemp.bottom-3);
pDC->LineTo(m_rcTemp.right-1,m_rcTemp.top+1);
pDC->MoveTo(m_rcTemp.left+1,m_rcTemp.top+iMediaAltura+1);
pDC->LineTo(m_rcTemp.left+3,m_rcTemp.bottom-4);
pDC->MoveTo(m_rcTemp.left+3,m_rcTemp.bottom-4);
pDC->LineTo(m_rcTemp.right-1,m_rcTemp.top);
//pDC->SelectObject(pOld);
}
void CAUICheckBox::PreSubclassWindow()
{
ModifyStyle(0,BS_OWNERDRAW);
m_MouseMgr.Init (m_hWnd);
CButton::PreSubclassWindow();
}
void CAUICheckBox::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CButton::OnLButtonDown(nFlags, point);
m_bPressBtn=TRUE;
m_bOldTemp=m_bCheckBtn;
Invalidate();
UpdateWindow();
}
void CAUICheckBox::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CButton::OnLButtonUp(nFlags, point);
CRect m_rect;
GetClientRect(&m_rect);
SetCheck(m_Checked ? 0 : 1);
if (m_rect.PtInRect(point))
{
if (m_bCheckBtn==TRUE)
m_bCheckBtn=FALSE;
else
m_bCheckBtn=TRUE;
m_bOldTemp=m_bCheckBtn;
m_bPressBtn=FALSE;
m_bSelected =FALSE;
Invalidate();
UpdateWindow();
}
}
void CAUICheckBox::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CButton::OnMouseMove(nFlags, point);
m_MouseMgr.OnMouseMove();
}
void CAUICheckBox::OnMouseOut ()
{
m_MouseMgr.OnMouseOut();
}
|
|
|
|
|
hello
i have a problem that can't resomve him.
i have a handel of window that have an EditBox and i want to fill them with a string .
i have try SetWindowText but it change the name of the bar of the window and i don't want that.
the window that i want to fill the it's the WinWORD Password.
can you help me
|
|
|
|
|
Use EnumChildWindows() to enumerate through the child windows of the dialog. When you find the edit box, you can use SetWindowText() then to fill it with your string.
Dave
|
|
|
|
|
Help please!!! We are running into the following problem:
How can we share global instance data among multiple parent-child thread branches under Win32?
Thread Local Storage can be used if you have two threads which each need
their own global instance of a class:
fooKey=TLSAlloc();
TLSSetValue(fooKey,new Foo()); //TLS for foo=new Foo();
foo=TLSGetValue(fooKey);
foo->bar(); //each thread gets its own foo instance
However, what if the two threads each spawn a new thread which needs
to address foo (and you can't pass foo in during the thread create because
the thread is created in a library call which we don't have access to):
Main Thread
/ \
thread A1 thread B1 foo=new Foo(); //our code
| |
thread A2 thread B2 //not our code
| |
thread A3 thread B3 foo->bar(); //our code
We want A3's foo instance to be the same as A1, and B3's instance
to be the same as B1, but for A1 and B1 to be different.
Here we can't use TLS because thread A3 would be different than A1
since their thread IDs are different.
We thought of making our own TLS which would use the parent thread
ID (I know it isn't a true parent-child relationship, but in this
case we are calling the spawning thread the parent) for the lookup
if there is no storage under the thread's own ID, but we haven't
found a Win32 API call that permits us to know the parent ID (and
again, if we were directly calling CreateThread, _beginthreadex
or other thread family functions,
we could pass the shared data wrapped in the thread parameter, but
unfortunately we aren't creating the thread ourselves so we can't pass data
in or even get the thread ID when it is created...in actuality, there
is even a 3rd thread in-between the other two but that isn't critical
to finding a solution here...)
Thanks for your help. If you have any suggestions, please send me a
email at ecomwang@yahoo.com.
|
|
|
|
|