|
For operators where the left argument is an "a" object, make the method a member of the class:
struct a
{
double d1, d2, d3;
a operator+ (const a& rhs) const;
};
a a::operator+ ( const a& rhs ) const
{
a retval;
retval.d1 = d1 + rhs.d1;
retval.d2 = d2 + rhs.d2;
retval.d3 = d3 + rhs.d3;
return retval;
} For operators where the left argument is not an "a", you need to make the method global:
a operator+ (const double d, const a& rhs )
{
a retval;
a.d1 = d + rhs.d1;
a.d2 = d + rhs.d2;
a.d3 = d + rhs.d3;
return retval;
} Note that if you had a class, and the global operator+ needed to access protected/private members of "a", then the global func would have to be declared as a friend.
--Mike--
http://home.inreach.com/mdunn/
This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use.
your with and
|
|
|
|
|
Hi
Is there a way to start an application (using ShellExecute(Ex)) and send it into the Systray instead of the taskbar?
regards
|
|
|
|
|
Is this your own application which you can modify or is it a third party app?
If it is your app, then you could add code so it checks for a command line parameter which if present minimizes the application to the system tray.
Michael
|
|
|
|
|
And if it's not your own app, perhaps you could SW_HIDE its main window (after locating it) and creating your own systray icon that SW_SHOWs the the main window. Rehiding the app to the systray would be a neat trick.
I believe there's a PC Mag utility (source code included) that does this.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I've been working on this task forever, but...
I am using IPropertyStorage and IPropertySetStorage to obtain and save the summary properties for an
xml file. When I save the xml file with new file data, it creates a new file and therefore doesn't
save the summary properties stream.
USES_CONVERSION;
TCHAR l_szChar[MAX_STR_SIZE+1];
long l_hGeneralInfo = 0;
CComBSTR l_vtPlanInfo;
CComPtr<ispwpersistenceagent> l_spIspwPersistenceAgent;
HRESULT hr = l_spIspwPersistenceAgent.CoCreateInstance(CLSID_spwPersistenceAgent);
if (FAILED(hr))
{
BSTR l_lErrMsg = L"Could not create instance of Persistence Agent";
MessageBox(p_hDlg, l_lErrMsg, _T(""), MB_ICONWARNING);
}
hr = l_spIspwPersistenceAgent->Load(m_szFilePath, VARIANT_TRUE, NULL);
if (FAILED(hr))
{
BSTR l_lErrMsg = L"Could not Load instance of Persistence Agent";
MessageBox(p_hDlg, l_lErrMsg, _T(""), MB_ICONWARNING);
}
// Prepare Persistence Agent for saving command and mission
hr = l_spIspwPersistenceAgent->CreateOrOpenSubElement(
0, GENERAL_INFO, &l_hGeneralInfo);
if (FAILED(hr))
{
BSTR l_lErrMsg = L"Could not Open subelement General Info";
MessageBox(p_hDlg, l_lErrMsg, _T(""), MB_ICONWARNING);
}
// Save the store plan command.
GetDlgItemText(p_hDlg, IDC_SOMEINFO, l_szChar, NSPW_PROP_MAX_STR_SIZE);
l_spIspwPersistenceAgent->put_SubElementValue(l_hGeneralInfo,
SOMEINFO,
CComVariant(T2OLE(l_szChar) ) );
// Save the store plan mission.
GetDlgItemText(p_hDlg, IDC_SOMEOTHERINFO, l_szChar, NSPW_PROP_MAX_STR_SIZE);
l_spIspwPersistenceAgent->put_SubElementValue(l_hGeneralInfo,
SOMEOTHERINFO,
CComVariant(T2OLE(l_szChar) ) );
l_spIspwPersistenceAgent->SaveAs(m_szFilePath, VARIANT_TRUE, NULL);
TCHAR szBuffer[256];
// Save the file properties.
CComPtr<ipropertysetstorage> l_spIPropertySetStorage;
// Open the existing root storage object in the file system.
HRESULT hr = StgOpenStorageEx(m_szFile, STGM_DIRECT|STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
STGFMT_ANY, NULL, NULL, NULL,
IID_IPropertySetStorage,
(void**)&l_spIPropertySetStorage );
if (FAILED(hr))
{
wsprintf(szBuffer, _T("StgOpenStorageEx: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("StgOpenStorageEx Call"), MB_OK);
I've been working on this task forever, but...
I am using IPropertyStorage and IPropertySetStorage to obtain and save the summary properties for an xml file. When I save the xml file with new file data, it creates a new file and therefore doesn't save the summary properties stream.
USES_CONVERSION;
TCHAR l_szChar[MAX_STR_SIZE+1];
long l_hGeneralInfo = 0;
CComBSTR l_vtPlanInfo;
CComPtr<ispwpersistenceagent> l_spIspwPersistenceAgent;
HRESULT hr = l_spIspwPersistenceAgent.CoCreateInstance(CLSID_spwPersistenceAgent);
if (FAILED(hr))
{
BSTR l_lErrMsg = L"Could not create instance of Persistence Agent";
MessageBox(p_hDlg, l_lErrMsg, _T(""), MB_ICONWARNING);
}
hr = l_spIspwPersistenceAgent->Load(m_szFilePath, VARIANT_TRUE, NULL);
if (FAILED(hr))
{
BSTR l_lErrMsg = L"Could not Load instance of Persistence Agent";
MessageBox(p_hDlg, l_lErrMsg, _T(""), MB_ICONWARNING);
}
// Prepare Persistence Agent for saving command and mission
hr = l_spIspwPersistenceAgent->CreateOrOpenSubElement(
0, GENERAL_INFO, &l_hGeneralInfo);
if (FAILED(hr))
{
BSTR l_lErrMsg = L"Could not Open subelement General Info";
MessageBox(p_hDlg, l_lErrMsg, _T(""), MB_ICONWARNING);
}
// Save the store plan command.
GetDlgItemText(p_hDlg, IDC_SOMEINFO, l_szChar, MAX_STR_SIZE);
l_spIspwPersistenceAgent->put_SubElementValue(l_hGeneralInfo,
SOMEINFO,
CComVariant(T2OLE(l_szChar) ) );
// Save the store plan mission.
GetDlgItemText(p_hDlg, SOMEOTHERINFO, l_szChar, MAX_STR_SIZE);
l_spIspwPersistenceAgent->put_SubElementValue(l_hGeneralInfo,
SOMEOTHERINFO,
CComVariant(T2OLE(l_szChar) ) );
l_spIspwPersistenceAgent->SaveAs(m_szFilePath, VARIANT_TRUE, NULL);
TCHAR szBuffer[256];
// Save the file properties.
CComPtr<ipropertysetstorage> l_spIPropertySetStorage;
// Open the existing root storage object in the file system.
HRESULT hr = StgOpenStorageEx(m_szFile, STGM_DIRECT|STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
STGFMT_ANY, NULL, NULL, NULL,
IID_IPropertySetStorage,
(void**)&l_spIPropertySetStorage );
if (FAILED(hr))
{
wsprintf(szBuffer, _T("StgOpenStorageEx: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("StgOpenStorageEx Call"), MB_OK);
::MessageBox(NULL, L"StgOpenStorageEx FAILED", L"ApplySummaryDialog", MB_OK);
return S_OK;
}
CComPtr<ipropertystorage> l_spIPropertyStorage;
// Open an interface pointer to the existing property set.
hr = l_spIPropertySetStorage->Open(FMTID_SummaryInformation,
STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
&l_spIPropertyStorage);
wsprintf(szBuffer, _T("Open Summary: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("HI"), MB_OK);
// If there is no existing property set,
if (FAILED(hr))
{
::MessageBox(NULL, L"l_spIPropertySetStorage->Open returned a FAILED", L"ApplySummaryDialog", MB_OK);
if (hr == STG_E_FILENOTFOUND )
::MessageBox(NULL, L"l_spIPropertySetStorage->Open returned STG_E_FILENOTFOUND so creating one", L"ApplySummaryDialog", MB_OK);
// Create the property set.
hr = l_spIPropertySetStorage->Create(FMTID_SummaryInformation,
&CLSID_spwFilePropShlExt,
PROPSETFLAG_DEFAULT,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
&l_spIPropertyStorage);
{
TCHAR tchBuffer[256];
_stprintf(tchBuffer, __TEXT("l_spIPropertySetStorage->Create failed w/error 0x%x\n", hr));
CComBSTR l_bstrErrorMsg(tchBuffer);
::MessageBox(NULL, l_bstrErrorMsg, L"ApplySummaryDialog", MB_OK);
}
return S_OK;
}
PROPSPEC l_aPropertySpec[1];
l_aPropertySpec[0].ulKind = PRSPEC_PROPID;
l_aPropertySpec[0].propid = PIDSI_AUTHOR;
PROPVARIANT l_aResults[1];
// Obtain the author.
hr = l_spIPropertyStorage->ReadMultiple( 1, l_aPropertySpec, l_aResults);
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->ReadMultiple: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("l_spIPropertyStorage->ReadMultiple Call"), MB_OK);
l_aResults[0].pszVal = "";
}
if ( l_aResults[0].vt != VT_LPSTR ) throw _T("vt is not VT_LPSTR");
CComBSTR l_bstrAuthor = l_aResults[0].pszVal;
// Save the author.
hr = l_spIPropertyStorage->WriteMultiple( 1, l_aPropertySpec, l_aResults, NULL );
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->WriteMultiple: 0x%x\n"), hr);
::MessageBox(NULL,
szBuffer,
_T("l_spIPropertyStorage->WriteMultiple Call"),
MB_OK);
NSPWPASSERROR(hr,
L"Failed to write author property to storage stream ",
CspwPropPageCtrl::ApplySummaryDialog);
}
l_aPropertySpec[0].ulKind = PRSPEC_PROPID;
l_aPropertySpec[0].propid = PIDSI_COMMENTS;
::MessageBox(NULL,
L"CALLING l_spIPropertyStorage->ReadMultiple",
_T("l_spIPropertyStorage->WriteMultiple Call"),
MB_OK);
// Obtain the comments.
hr = l_spIPropertyStorage->ReadMultiple( 1, l_aPropertySpec, l_aResults);
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->ReadMultiple: 0x%x\n"), hr);
::MessageBox(NULL,
szBuffer,
_T("l_spIPropertyStorage->ReadMultiple Call"),
MB_OK);
l_aResults[0].pszVal = "";
}
CComBSTR l_bstrComment = l_aResults[0].pszVal;
::MessageBox(NULL,
L"Calling l_spIPropertyStorage->WriteMultiple",
_T("Comments"),
MB_OK);
// Save the comments.
hr = l_spIPropertyStorage->WriteMultiple( 1, l_aPropertySpec, l_aResults, NULL );
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->WriteMultiple: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("l_spIPropertyStorage->WriteMultiple Call"), MB_OK);
NSPWPASSERROR(hr,
L"Failed to write comments property to storage stream ",
CspwPropPageCtrl::ApplySummaryDialog);
}
::MessageBox(NULL,
L"Calling FreePropVariantArray",
_T("Comments"),
MB_OK);
hr = FreePropVariantArray(2, l_aResults);
::MessageBox(NULL, L"CALLED FreePropVariantArray", _T("FreePropVariantArray Call"), MB_OK);
A colleague has told me it's because I'm trying to save a compound document as a non-compound document.
The l_spIPropertySetStorage->Open call normally fails, so I create the interface pointer. Can someone
please tell me how to fix this?
return S_OK;
}
CComPtr<ipropertystorage> l_spIPropertyStorage;
// Open an interface pointer to the existing property set.
hr = l_spIPropertySetStorage->Open(FMTID_SummaryInformation,
STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
&l_spIPropertyStorage);
wsprintf(szBuffer, _T("Open Summary: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("HI"), MB_OK);
// If there is no existing property set,
if (FAILED(hr))
{
::MessageBox(NULL, L"l_spIPropertySetStorage->Open returned a FAILED", L"ApplySummaryDialog", MB_OK);
if (hr == STG_E_FILENOTFOUND )
::MessageBox(NULL, L"l_spIPropertySetStorage->Open returned STG_E_FILENOTFOUND so creating one", L"ApplySummaryDialog", MB_OK);
// Create the property set.
hr = l_spIPropertySetStorage->Create(FMTID_SummaryInformation,
&CLSID_spwFilePropShlExt,
PROPSETFLAG_DEFAULT,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
&l_spIPropertyStorage);
{
TCHAR tchBuffer[256];
_stprintf(tchBuffer, __TEXT("l_spIPropertySetStorage->Create failed w/error 0x%x\n", hr));
CComBSTR l_bstrErrorMsg(tchBuffer);
::MessageBox(NULL, l_bstrErrorMsg, L"ApplySummaryDialog", MB_OK);
}
return S_OK;
}
PROPSPEC l_aPropertySpec[1];
l_aPropertySpec[0].ulKind = PRSPEC_PROPID;
l_aPropertySpec[0].propid = PIDSI_AUTHOR;
PROPVARIANT l_aResults[1];
// Obtain the author.
hr = l_spIPropertyStorage->ReadMultiple( 1, l_aPropertySpec, l_aResults);
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->ReadMultiple: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("l_spIPropertyStorage->ReadMultiple Call"), MB_OK);
l_aResults[0].pszVal = "";
}
if ( l_aResults[0].vt != VT_LPSTR ) throw _T("vt is not VT_LPSTR");
CComBSTR l_bstrAuthor = l_aResults[0].pszVal;
// Save the author.
hr = l_spIPropertyStorage->WriteMultiple( 1, l_aPropertySpec, l_aResults, NULL );
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->WriteMultiple: 0x%x\n"), hr);
::MessageBox(NULL,
szBuffer,
_T("l_spIPropertyStorage->WriteMultiple Call"),
MB_OK);
NSPWPASSERROR(hr,
L"Failed to write author property to storage stream ",
CspwPropPageCtrl::ApplySummaryDialog);
}
l_aPropertySpec[0].ulKind = PRSPEC_PROPID;
l_aPropertySpec[0].propid = PIDSI_COMMENTS;
::MessageBox(NULL,
L"CALLING l_spIPropertyStorage->ReadMultiple",
_T("l_spIPropertyStorage->WriteMultiple Call"),
MB_OK);
// Obtain the comments.
hr = l_spIPropertyStorage->ReadMultiple( 1, l_aPropertySpec, l_aResults);
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->ReadMultiple: 0x%x\n"), hr);
::MessageBox(NULL,
szBuffer,
_T("l_spIPropertyStorage->ReadMultiple Call"),
MB_OK);
l_aResults[0].pszVal = "";
}
CComBSTR l_bstrComment = l_aResults[0].pszVal;
::MessageBox(NULL,
L"Calling l_spIPropertyStorage->WriteMultiple",
_T("Comments"),
MB_OK);
// Save the comments.
hr = l_spIPropertyStorage->WriteMultiple( 1, l_aPropertySpec, l_aResults, NULL );
if (FAILED(hr))
{
wsprintf(szBuffer, _T("l_spIPropertyStorage->WriteMultiple: 0x%x\n"), hr);
::MessageBox(NULL, szBuffer, _T("l_spIPropertyStorage->WriteMultiple Call"), MB_OK);
NSPWPASSERROR(hr,
L"Failed to write comments property to storage stream ",
CspwPropPageCtrl::ApplySummaryDialog);
}
::MessageBox(NULL,
L"Calling FreePropVariantArray",
_T("Comments"),
MB_OK);
hr = FreePropVariantArray(2, l_aResults);
::MessageBox(NULL, L"CALLED FreePropVariantArray", _T("FreePropVariantArray Call"), MB_OK);
A colleague has told me it's because I'm trying to save a compound document as a non-compound document. The l_spIPropertySetStorage->Open call normally fails, so I create the interface pointer.
Can someone please tell me how to fix this?
Lilian
|
|
|
|
|
Hi,
I have a graphics ActiveX control sitting on a CFormView derived class in an SDI application. I recently found an article about tooltips from April '97 in MSJ searching through MSDN. I've implemented that solution and it seems to work except for a few little problems that I was wondering if someone has seen before.
When I get the tooltip that is over a particular area of the image (hotspot) the tooltip shows up right under the mouse. It also shows up at the bottom of the CFormView window, so I now get two tooltips and I can't figure out how to get rid of the one along the bottom of the window.
Following is the code that I'm using, any help in this matter is greatly appreciated.
Thanks,
Craig
void CImageViewer::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
if (m_ToolTip.Create(&m_lead, TTS_ALWAYSTIP) &&
m_ToolTip.AddTool(&m_lead))
{
m_ToolTip.SendMessage(TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);
m_ToolTip.SendMessage(TTM_SETDELAYTIME, TTDT_AUTOPOP, SHRT_MAX);
m_ToolTip.SendMessage(TTM_SETDELAYTIME, TTDT_INITIAL, 200);
m_ToolTip.SendMessage(TTM_SETDELAYTIME, TTDT_RESHOW, 200);
}
else
{
TRACE("Error in creating ToolTip");
}
}
BOOL CImageViewer::PreTranslateMessage(MSG* pMsg)
{
if (::IsWindow(m_ToolTip.m_hWnd) && pMsg->hwnd == m_lead.m_hWnd)
{
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
case WM_MOUSEMOVE:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
{
if(vecRects.size() > 0)
{
CPoint pt(pMsg->pt);
ScreenToClient(&pt);
float zoom = m_lead.GetPaintZoomFactor();
float ix, iy;
int xscroll, yscroll;
xscroll = m_lead.GetScrollPos(SB_VERT);
yscroll = m_lead.GetScrollPos(SB_HORZ);
float newzoom = zoom / 100;
ix = (pt.x + xscroll) * newzoom;
iy = (pt.y + yscroll) * newzoom;
pMsg->pt.y = iy;
pMsg->pt.x = ix;
m_lead.SetAutoRepaint(TRUE);
m_ToolTip.RelayEvent(pMsg);
}
m_ToolTip.RelayEvent(pMsg);
break;
}
default:
break;
}
}
return CFormView::PreTranslateMessage(pMsg);
}
BOOL CImageViewer::OnToolTipNeedText(UINT id, NMHDR * pNMHDR, LRESULT * pResult)
{
BOOL bHandledNotify = FALSE;
CPoint CursorPos;
VERIFY(::GetCursorPos(&CursorPos));
ScreenToClient(&CursorPos);
CRect ClientRect;
GetClientRect(ClientRect);
if (ClientRect.PtInRect(CursorPos))
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
m_pRectHit = HitTest(CursorPos);
if (m_pRectHit)
{
CString strTip;
strTip.Format("%s %s", m_pRectHit->szPartNumber.c_str(),
m_pRectHit->szDescription.c_str());
ASSERT(strTip.GetLength() < sizeof(pTTT->szText));
::strcpy(pTTT->szText, strTip);
bHandledNotify = TRUE;
}
else
{
pTTT->szText[0] = 0;
}
}
return bHandledNotify;
}
void CImageViewer::OnMouseMoveLeadctrl(short Button, short Shift, long x, long y)
{
if (::IsWindow(m_ToolTip.m_hWnd))
{
CPoint point(x, y);
const CRects* pRectHit = HitTest(point);
if (!pRectHit || pRectHit != m_pRectHit)
{
m_ToolTip.Activate(FALSE);
}
if (pRectHit)
{
m_ToolTip.Activate(TRUE);
m_pRectHit = pRectHit;
}
}
}
|
|
|
|
|
Hi,
When I print a draft I want to draw in the top of the page a little subindex, something like "(1/1)"...("1/2"), ...
I would like to print it in the smallest possible readable and common font for Windows, wich one is it ?
I would like to know how to calculate the size of that in milimeters in order to substract it to the actual size of the paper just to resize the metafile ( or if it´s possible to print it in the margin and not to take any extra place).
Can you help me ? Thanks, Bye
Braulio
|
|
|
|
|
If you have a printer DC to print with, you can query it to find out how many pixels/inch you get like this:
x_pixels = pDC->GetDeviceCaps(LOGICALPIXELX) ;
y_pixels = pDC->GetDeviceCaps(LOGICALPIXELSY) ;
x_size = pDC->GetDeviceCaps(HORZRES) ;
y_size = pDC->GetDeviceCaps(VERTRES) ;
From these values you can determine what minimum font size you would need, (lets say you wanted your test to be .1 inch high). You can then offset you regular printing from that point on.
The above was written from memory , so the passed parameters may not be exactly correct.
Roger Allen the man
|
|
|
|
|
Problem:
I am trying to get an IHTMLWindow2 interface from the WebBrowser control. I am successful at querying for a IWebBrowser2 interface, but I have yet to figure out how to retrieve an IHTMLWindow2 interface. Anyone that has information reguarding this please feel free to respond.
Jamie Parent
VC++ Software Deveoloper
Digital Immersion
|
|
|
|
|
I tried to get an IHTMLWindow2 interface using your suggestion, but was unsuccessful. I need to use the function HRESULT IHTMLWindow2::get_history(IOmHistory **p), but I have yet to find a way to reach that interface.
Perhaps I am not looking at the right place or that interface is not reachable. I am a little new to this area of VC++, please excuse me if the answer might be apparent.
|
|
|
|
|
I have used the makefile(s) that VC++ generates in order to create a batch file that could automate system rebuilds. The problem with it is that it is still a manual process to export the makefile, especially following some project change, ie. adding new files. Is there a way to put together a batch file that can be executed such that it will cause VC++ projects to be completely rebuilt.
What I'm lookng for is something like the following
C:\...\msdev.exe -RebuildAll Project1.dsp -Silent -ErrorLog BuildProject1Error.txt
and to then have the project loaded and all configurations rebuilt from scratch. This would also include any special pre-build and post build operations.
Anyone know of some way of doing this?
Thanks.
Chris Meech
Is such a
|
|
|
|
|
VC++ User's Guide/Working with Projects/How Do I.../Building a Project/Building a Project from the Command Line.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz, you keep this up and you will be getting my Gold Star for the week.
I have just traversed into the User's manual to the page you hilighted for me and that is exactly what I'm looking for.
Thanks once again.
Chris Meech
|
|
|
|
|
How can i let the users browse a DIRECTORY ( not a file! )
(let's say when cliking on the BROWSE button)???
it would be a great help
|
|
|
|
|
If you are looking for a DirOpenDialog, use this function:
SHBrowseForFolder( BROWSEINFO *mPtrBInfo );
Look in MSDN for detail info about the BROWSEINFO structure.
You can use this for Printer, Network resource, etc...
BOOL SelectFolder( CString& nFolderName, LPCTSTR nTitulo, UINT nFlags )
{
BOOL bRet;
char pszPath[MAX_PATH];
BROWSEINFO mPtrBInfo;
mPtrBInfo.hwndOwner = NULL; // HWND
mPtrBInfo.pidlRoot = NULL; // LPCITEMIDLIST
mPtrBInfo.pszDisplayName = pszPath; // LPTSTR
mPtrBInfo.lpszTitle = nTitulo; // LPCTSTR
mPtrBInfo.ulFlags = nFlags | BIF_RETURNONLYFSDIRS;
mPtrBInfo.lpfn = NULL; // BFFCALLBACK
mPtrBInfo.lParam = 0L; // LPARAM
mPtrBInfo.iImage = 0; // int
if ( OleInitialize( NULL ) != S_OK )
AfxMessageBox( "Error inicializando OLE" );
ITEMIDLIST *mPtrIList = SHBrowseForFolder( &mPtrBInfo );
bRet = SHGetPathFromIDList( mPtrIList, pszPath );
OleUninitialize();
if ( bRet )
nFolderName = pszPath;
return bRet;
}
|
|
|
|
|
How can I make an Editbox control visible or invisible
throw the code.
I know : object.visible=1
but what is the object???
can some one can give an example
( let's say that the edit controll ID is ID_EDIT2
|
|
|
|
|
CWnd* pCtrl = GetDlgCtrlID(ID_EDIT2);
if ( pCtrl )
if ( pCtrl->IsVisible() )
pCtrl->ShowWindow(SW_HIDE);
else
pCtrl->ShowWindow(SW_NORMAL);
Is this what you are looking for?
Chris
|
|
|
|
|
Shouldn't that be
<br />
CWnd* pCtrl = GetDlgItem(ID_EDIT2);<br />
Michael
|
|
|
|
|
Thanks, Michael.
You are correct. In my haste to post, I forgot to try and compile
Chris
|
|
|
|
|
When using very large coordinates for GDI calls there's seems to be severe performance hits. (Let's say I have a client area (0, 0, 100, 100) and call make these calls: dc -> MoveTo(-30000, -30000); dc -> LineTo(30000, 30000);)
I store my objects as floats, do my own scaling, and since allow a very generous scale these large values will show up even for normal objects after conversion to device coordinates.
Adding a clipping region doesn't seem to help so I want to know if I have to do the clipping myself?
I'm using Windows 2000 and I don't think 16-bit GDI is the cause of the problem.
|
|
|
|
|
Hello,
Our projects currently use ifsteam to read in a custom configuration text file (just comma delimited). We just realized (actually QA did) that these files are not locked when opened and can cause some major problems when both projects are run at the same time. Without re-writing a huge portion of code, is there an easy way to lock a file when it is opened? I couldn't find any ios:: flags that would do this for ifstream. We are using VC++ 6.0 and the standard STL library that it ships with.
Thanks in advance!
|
|
|
|
|
There's a 3rd parameter to open which defaults to filebuf::openprot. Search for that definition in the ifstream header or your docs. It's defined as the share/prot mode.
Todd Smith
|
|
|
|
|
I think I realized that there's more to this on our side as well. The file is already closed when the other program opens it up, so I need to do some file locking to prevent this.
Thanks for the reply. The help files for STL that ships with VC++ is horrendous and needs a face lift. Just displaying a cryptic class doesn't count as help in my book!
Derek
|
|
|
|
|
Hi,
perharps it's me just not searching deep enough, but I can't seem to find basic instructions to make and use a DLL. Where should I start?
Thanks!
|
|
|
|
|
I had exactly the same problem when starting out.
Check out : http://www.codeguru.com/dll/index.shtml
There are different types, the main issues are whether you require to build upon MFC objects, or are dealing with C++, as opposed to simply calling a C function.
The other question is whether you want to link at runtime.
The simplest way to get started is probably to create a function declared
as follow, in a WIN32 DLL App Wizzard Project:
extern "C" __declspec(dllexport) long test(char *szTestParam)
Then to use the DLL in another project, you must adjust the project settings to link to the lib file for the project (in the library text box).
And declare
extern "C" __declspec(import) long test(char *szTestParam;
Your then free to use the function.
Simple as that, (Well! Once you get stuck into it, it's straight forward!)
Have Fun Hope I've Helped
Rich
|
|
|
|
|