|
You might try showing us how you are doing your calculations with some code. Showing us only the line withou cout doesn't help us figure out how you calculations can be mysteriously "wrong".
Try to isolate it to as small of a section of code as you possibly can.
|
|
|
|
|
Hi,
Here is a function (above) to browse Computers names on network.
It work but I have a problem to get the name of machine which is selected.
If i use this call :
CString strDir = BrowseForFolder(m_hWnd, "Select a folder", 0 );
with browseInfo.pidlRoot=NULL;
I obtain the name of folder selected.
BUT WITH THIS CALL
CString strDir = BrowseForFolder(m_hWnd, "selected a computer", BIF_BROWSEFORCOMPUTER );
with browseInfo.pidlRoot=(_ITEMIDLIST *)0x12;
The function browse very match only computer but my variable strDir is empty at the end.
I try to use this other function :
SHGetSpecialFolderPath(hWnd,szBuffer,CSIDL_NETHOOD ,0);
but i have a entry point problem to shell32.dll
Can anybody help me to get computer name?
Function
================================================================================
CString& CTestDlg::BrowseForFolder(HWND hWnd, LPCSTR lpszTitle, UINT nFlags)
{
static CString strResult = "";
LPMALLOC lpMalloc; // pointer to IMalloc
if (::SHGetMalloc(&lpMalloc) != NOERROR)
return strResult; // failed to get allocator
char szDisplayName[_MAX_PATH];
char szBuffer[_MAX_PATH];
BROWSEINFO browseInfo;
browseInfo.hwndOwner = hWnd;
// set root at Network Neighborhood ( if NULL then set root at Desktop )
browseInfo.pidlRoot = (_ITEMIDLIST *)0x12;
browseInfo.pszDisplayName = szDisplayName;
browseInfo.lpszTitle = lpszTitle;
browseInfo.ulFlags = nFlags;
browseInfo.lpfn = NULL; // not used
browseInfo.lParam = 0; // not used
LPITEMIDLIST lpItemIDList;
if ((lpItemIDList = ::SHBrowseForFolder(&browseInfo))
!= NULL)
{
// Get the path of the selected folder from the
// item ID list.
if (::SHGetPathFromIDList(lpItemIDList, szBuffer))
{
// At this point, szBuffer contains the path
// the user chose.
if (szBuffer[0] == '\0')
{
// SHGetPathFromIDList failed, or
// SHBrowseForFolder failed.
//AfxMessageBox(IDP_FAILED_GET_DIRECTORY,MB_ICONSTOP|MB_OK);
return strResult;
}
// We have a path in szBuffer!
// Return it.
strResult = szBuffer;
return strResult;
}
else
{
// The thing referred to by lpItemIDList
// might not have been a file system object.
// For whatever reason, SHGetPathFromIDList
// didn't work!
//AfxMessageBox(IDP_FAILED_GET_DIRECTORY,MB_ICONSTOP|MB_OK);
return strResult; // strResult is empty
}
lpMalloc->Free(lpItemIDList);
lpMalloc->Release();
}
// If we made it this far, SHBrowseForFolder failed.
return strResult;
}
|
|
|
|
|
I have a SDI application with a splitter: treeview on left and dialog in a formview on right. Every time I open a file, the window resizes to the default size (and only if it was bigger than the default size). What is causing that and how can I solve it.
Thanks
(Sorry if my English is not perfect: French dude)
|
|
|
|
|
i need to do a couple of things with TCL in a component of C++.
does anybody knows how can i do that????
i got the TCL script and the code of the component, but i need to run a script of TCL in the component.
Thanks!!!!!
|
|
|
|
|
I'm currently writing a Client Server Type application. In my experience in the past with DCOM its performance, even when optimized for DCOM, hasn't been that great and its reliablity in a WAN environment has been nothing to write home about. Unfortunatly for various reasons MTS isn't an option for me at this point. I have messed with Sockets in VB but not in VC++. Is it worth my time to investigate using sockets as apposed to DCOM especially since it appears that Microsoft is moving away from DCOM in favor of its .Net initiatives(SOAP & XML). In your experiences am I going in the wrong direction thinking of sockets. Am I just really far off in my thoughts here. Any advice would be appreciated. Thanks in advance.
|
|
|
|
|
I have two classes in a DLL. One class CStringDialog is for a dialog box. The other class CCaller contains one function DisplayDialog which calls the dialog using the DoModal function.
When I call the DisplayDialog function from another executable, the application get to the function, but does not display the dialog.
Any suggestions would be appretiated.
|
|
|
|
|
The code is probably looking in your application's resources for the dialog box resources. Try something like the following:
HINSTANCE h = (HINSTANCE)::GetModuleHandle("YourDLLName");
ASSERT(h);
HINSTANCE hPrevious = AfxGetResourceHandle();
AfxSetResourceHandle(h);
dlg.DoModal();
AfxSetResourceHandle (hPrevious);
|
|
|
|
|
I need to set the default file open folder for open file in a doc/view/mdi app. I know about the win32 api structure containing an initial folder parameter. The file is serialized.
Do I have to completely subclass the dialog or is there a way to modify that structure variable capturing the menu message on File Open and then pass to the standard CFileOpen without rewriting all of it?
Also, what module (MainFrame, ChildFrame, etc, do I capture the message and set the initial folder variable, then pass on to the standard function?
I do not want to start in My Documents but will load the default path from a parameter I've stored successfully in the registry.
This is a multi-template app depending on file extension, but for now all the files will be stored in one default folder. Nothing to set in the menu resource string tables for this?
|
|
|
|
|
|
but can I catch this in the framework without subclassing the entire file open?
In the doc On Open? elsewhere in the wiz generated doc/view?
|
|
|
|
|
Hi,
You can do it by changing the members of your CFileDialog before calling DoModal() :
CFileDialog(TRUE, .......);
dlg.m_ofn = ...
if (dlg.DoModal() == IDOK)
{
// Do Open thing here
}
Hope this helps,
Berkut
|
|
|
|
|
Hi,
I work in Visual C++ 6.0 and i want to get all computer names on a network
How can i get (enumerate) theses machines names?. Is there network browsing dialogs in C++ std or MFC ?
Thanks in advance
|
|
|
|
|
There is a sample under the tree controls on this site that enumerates the network. If you get it to be able to also browse target machines, and files, please let me know.
I got close, but not close enough.
|
|
|
|
|
Hi
I am using GetDeviceCaps(BITSPIXEL) to retrieve color bits for each pixel. If GetDeviceCaps(BITSPIXEL) returns 16 bits per pixel, does anyone know how to figure out if this 16 bpp is in 565, 1555 or 556 formats?
Thanks for any replies!
Kim
|
|
|
|
|
Hi.
I'm trying to learn how to make .inf setup files for a cab. Does anybody know of a good tutorial i can read. The MSDN is not much help. I'm trying to add keys to the registry, but they do not get added..
Chris
|
|
|
|
|
Hi Chris,
Why not u use Installshield for making the setup program. It is easy and u can have Licence Serial Number for ur product also.
Let me know,is helpful to u ?
Manish
|
|
|
|
|
Hi.
I'm trying to learn how to make .inf setup files for a cab. Does anybody know of a good tutorial i can read. The MSDN is not much help. I'm trying to add keys to the registry, but they do not get added..
Chris
|
|
|
|
|
Browser Helper Object applies to both IE and Windows Explorer. Can I have some ways to differentiate these two?
Thanks all!
|
|
|
|
|
Hi,
I have to copy text from 4th column of ListCtrl (in report view) and set the clipboard to that string value.
I have the text in a CString var but the problem is that I cant copy that value fron a CString to clipboard.
Any ideas?
Ammar
|
|
|
|
|
Try to take a look at: SetClipboardData()
- Anders
|
|
|
|
|
Drawing Bitmap on view(DC) with Clipping Region Operate well.
But, Drawing On PrintPreview(DC) Don't operate.
Please See My Code.
CBitmap Bitmap, *pOldBitmap;
Bitmap.LoadBitmap(IDB_BITMAP1);
CDC MemDC;
MemDC.CreateCompatibleDC( pDC );
pOldBitmap = MemDC.SelectObject( &Bitmap );
pDC->SetMapMode( MM_TEXT);
CPoint pt[3];
pt[0] = CPoint( 0, 0 );
pt[1] = CPoint( 0, 480);
pt[2] = CPoint( 640, 480);
CRgn ClipRgn;
CRgn rgnRect;
rgnRect.CreateRectRgn( 0, 0, 640, 480 );
pDC->BeginPath();
pDC->Polygon( pt, 3);
pDC->EndPath();
pDC->StrokePath();
ClipRgn.CreatePolygonRgn(pt, 3, ALTERNATE);
ClipRgn.CombineRgn( &ClipRgn, &rgnRect, RGN_AND );
if( pDC->IsPrinting() ) {
pDC->SelectClipRgn( &ClipRgn );
pDC->StretchBlt( 0, 0, 1000, 1000,
&MemDC,0,0,640,480, SRCCOPY );
}
else{
pDC->StretchBlt( 0, 0, 1000, 1000, &MemDC, 0, 0,
640,480, SRCCOPY );
}
MemDC.SelectObject(pOldBitmap);
MemDC.DeleteDC();
Bitmap.DeleteObject();
I want know How to use SelectClipRgn() function with
printpreview state
thanks
|
|
|
|
|
I would like to learn how to do this using Visual C++/MFC:
From my dialog-based program, send a message to an IE window and set the cursor(focus) on one object like the link "Visual C++" on this page. Or send a message to this already-executed IE to connect to a specific URL. How should I do that?
Thanks a lot!
|
|
|
|
|
Simply implement a "Browser helper object". There are examples in MSDN called IEHelper.
You can control the IE (and also the windows explorer, active desktop) by invoking its methods (e.g. navigate, goback, goforward, ...) or asynchronously obtain the events from IE when the items on it are being clicked.
Of course, you can access the DHTML model (e.g. any HTML elements on the page) and locate the cursor whenever you like.
If you are familiar with javascript, that would be a big help in doing with dhtml too.
|
|
|
|
|
I'm working on sending keyboard events from my code using Visual C++.Now I can send keyborad events using the fuction "keybd_event".
for example: char pChar = 'a';
SHORT ks = VkKeyScan(pChar);
BYTE key = ks & 0xFF;
keybd_event(key,0,0,0);
sends an message as if I pressed the button 'a'
The scan code '0x61' stands for the key 'a' on the keyboard,what about the code of the combination of 'Alt+a' or 'ctrl+a'? I would like to know what are the scan codes that stand for two key combinations of the keyboard. Or is this any other way to send such information from my code?
Thanks a lot!
|
|
|
|
|
The 'other' keys, like arrows, alt, etc. all have VK codes, such as VK_LEFT and VK_ALT. I *suspect* you could add these values to the values of keys, that they each set a high bit. This is just a guess, but hopefully will put you on the right track.
|
|
|
|