|
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.
|
|
|
|
|
Threads A3 and B3 are executing your code?
Do you get to specify what code that is?
That may be the way of transmitting the
information you need.
I.e. if you are prevented from passing on a
user defined value and are only allowed to
pass on the your thread's entry point, then
create a sort of thunking table of functions
which call your primary thread entry point and
pass on the index into the table.
Here's how it could work. A1 acquires an index
from a class that assigns table indices. So
now A1 owns index I5 for instance. B1 does the
same and gets index I6. Now when A1 passes
control to A2 (not yours) it specifies a thread
entry point of T[I5]. B1 does the same with an
entry point of T[I6].
So now their code in A2 creates a thread A3,
starting at T[I5]. This means your A3 thread can
determine who caused it to be created. voila.
Same for B.
From there it is easy to keep indexed foo objects
or what have you...
|
|
|
|
|
hello
i have a problem that can't resomve him
|
|
|
|
|
Well we can't help unless you tell us what your problem is
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
sorry i have a problem whene i write this thread.
i have a handel of a window(it don't belongs to my application)and i want to find the handel of the EditBox that was in this window.
because i want to fill this EditBox with a string .
|
|
|
|
|
I have a Key in registry which contains two values USERID and PASSWORD .I write the value using the following statements .
CString m_User="XYZ";
CString m_Pwd="XYZ";
char * puser;
char *pPwd;
char user[50];
char Pwd[50];
//change it from CString to const char
pUser=m_user.getBuffer[50];
m_User.ReleaseBuffer{50];
strcpy(user,pUser);
//Similar steps are done for password
RegQueryValueEx(hKey,"PASSWORD",NULL,NULL,(BYTE*)password,&dwbytes);
RegQueryValueEx(hKey,"USERID",NULL,NULL,(BYTE*)user,&dwbytes);
Now i read back from teh registry using the following statements ..
RegQueryValueEx(hKey,"USERID",NULL,NULL,(BYTE*)user,&dwbytes);
RegQueryValueEx(hKey,"PASSWORD",NULL,NULL,(BYTE*)password,&dwbytes);
SUprisingly teh APPLICATION EXITS ...
but if read it in the reverse order .ie
RegQueryValueEx(hKey,"PASSWORD",NULL,NULL,(BYTE*)password,&dwbytes);
RegQueryValueEx(hKey,"USERID",NULL,NULL,(BYTE*)user,&dwbytes);
SUrprsingly i do not get any error ..
Can some body solve this mystreious problem
|
|
|
|
|
That because your password is probably longer than userid anyway...
dwbytes is [in/out] see msdn
You should do something like this:
dwbytes = 50;
RegQueryValueEx(hKey,"PASSWORD",NULL,NULL,(BYTE*)password,&dwbytes);
dwbytes = 50;
RegQueryValueEx(hKey,"USERID",NULL,NULL,(BYTE*)user,&dwbytes);
|
|
|
|
|
Thanks a loT !!!!!!!It works .Just one more question ...
There are different types of characters like
char* ,TCHAR ,WCHAR ,LPTSTR ,LPCTSTR etc ...
what is the difference between them ,or u can just some place where i can find teh difference easily ???
Nothing WOrthwhile is achieved without deep thought and hard work .
|
|
|
|
|
|
The article was excellent .Thanks a lot !!!!!This site is defintely wonderfull
|
|
|
|
|
you should not use CString::GetBuffer to get a const char pointer to the string... that pointer that GetBuffer returns is only guaranteed to be valid until you call ReleaseBuffer.
CString has a const char operator, and you can simply use the CString as if it were a const char anyway. so this would work:-
strcpy(user, m_user);
In your code, becuase you have released the buffer before you strcpy, it may not work.
Furthermore, you don't even need the char user[] to write to the registry. You could write direct from the CString, simply by casting (BYTE *)(char *)m_user .
#include <beer.h>
|
|
|
|
|