|
I have also found that it helps to reset the BufferSize parameter to actual buffer size on each iteration. It is an IN/OUT parameter, so it gets messed up each iteration.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
DWORD dwIndex=0;
TCHAR lpValueName[MAX_PATH]={0};
TCHAR lpValue[MAX_PATH]={0};
BYTE lpData[MAX_PATH]={0};
long lEnumFlag=ERROR_SUCCESS;
MapIDToValue mapIdToValues;
while(lEnumFlag==ERROR_SUCCESS)
{
DWORD dwValueName=MAX_PATH,dwData=MAX_PATH;
lEnumFlag=RegEnumValue(hRegKey.m_hKey,
dwIndex,
lpValueName,
&dwValueName,
NULL,
NULL,
lpData,
&dwData);
if(lEnumFlag==ERROR_SUCCESS)
{
long lID=_ttol(lpValueName);
lstrcpy(lpValue,(const TCHAR*)lpData);
mapIdToValues.insert(MapIDToValue::value_type(lID,lpValue));
dwIndex++;
}
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
map-mode for CView DC is default (MM_TEXT), for printer is:
//-------------------------
int iMapMode=dc.SetMapMode(MM_ANISOTROPIC);
const int iLogX=dc.GetDeviceCaps(LOGPIXELSX);
const int iLogY=dc.GetDeviceCaps(LOGPIXELSY);
dc.SetViewportExt(iLogX,iLogY);
dc.SetWindowExt(100,100);
//-------------------------
lfHeight of LOGFONT is -11.
after the LOGFONT has been selected to DCs, I use GetTextExtent() function to obtain text's height.
for CView DC, text height is 14.
for printer DC, text height is 12.
how to change lfHeight of LOGFONT to keep same height for text in both CView and printer DCs?
|
|
|
|
|
Your text height is being scaled based on your window/viewport settings.
You've hardcoded 100,100 for the window extent so I guess you can adjust those up or down until
GetTextExtent() returns equal values for both DCs.
Why do you think they should be equal?
Mark
|
|
|
|
|
Hi all,
How can I add My own control , say a combo box one print preview controll bar.
In print preview control bar we have by default 7 buttons , they are Print,Next Page,Prev Page,Two Page,Zoom In,Zoom Out, Close .
I need to put my own controll, say a combo box along with the 7 button I have mentioned above, How it is possible .
Please Help me.
Thanks in Advance.
George K Jolly
|
|
|
|
|
Do you have MSN?
I want to have many friends
|
|
|
|
|
Hi All,
I m creating a MFC Dll -> Regular Dll with statically linked MFC.
In this Dll project, I have a Dialog Box. I tried to create a Web Browser on this dialog box in two ways:
1: Insert ActiveX control
2: Using CHtmlView class
In both cases, I failed. No compilation err generates.But,
--->> If I use first way (Web Browser Control) even dialog box not created.
--->> If I create CHtmlView object at runtime using Create(..) function, Assertion Faied err generates when I call Create function for CHtmlView object.
CODE IS AS BELOW:
/*********************************************/
//Global function in DLL App class #####################
BOOL __stdcall ShowFiles()
{
CDlg dlg;
dlg.DoModal();
return TRUE;
}
/*********************************************/
/*********************************************/
//In Dialog class ###############################
BOOL CDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
GetWindowRect(&rect);
//m_View declared in .h file
m_View.MoveWindow(&rect);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
int CDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
HINSTANCE m_hInst = AfxGetResourceHandle();
TRY
{
HINSTANCE m_hInst2 = ((CDllApp*)AfxGetApp())->hI; //theApp.m_hInstance
AfxSetResourceHandle(m_hInst2);
CRect rect;
GetWindowRect(&rect);
m_View.Create(NULL,_T(""),WS_CHILD|WS_VISIBLE,rect,this,AFX_IDW_PANE_FIRST);
m_View.ShowWindow(SW_MAXIMIZE);
}
CATCH_ALL(e)
{
e->ReportError();
}
END_CATCH_ALL
AfxSetResourceHandle(m_hInst);
return 0;
}
If any one has the soultion, plz reply ASAP.
Thanks in advance,
_______________
-------//-----
//____//
//-----
____// \\
---// \\AKESH
|
|
|
|
|
Hi all,
I need to compile a file from command line and wait for its execution.
What is the method?
I tried _spawnl but its not working.
Please help me.
Regards,
Nabi
|
|
|
|
|
In C++ the easiest way is to use the system CRT function.
#include <process.h>
int main()
{
system("Notepad.exe");
return 0;
}
Steve
|
|
|
|
|
It's great.
I also have this question.
I want to have many friends
|
|
|
|
|
kevinalphaxz wrote: I want to have many friends
That's not a question! 
|
|
|
|
|
if i try to include fstream.h and vector.h like this
#include <fstream.h>
#include <vector.h>
some error occured, what should i do?
|
|
|
|
|
The standard library include files don't end in ".h". Use #include <vector> instead, for example.
Steve
|
|
|
|
|
Could you be more specific about the error that occurs? Cause, I don't agree with Steve about the .h .... I mean I use it all the time and it work ????
Sorry My bad Steve ... are you talking about the vector header file??? If you are ... my bad.
The only programmers that are better than C programmers are those who code in 1's and 0's.....
 Programm3r
|
|
|
|
|
Programm3r wrote: Could you be more specific about the error that occurs? Cause, I don't agree with Steve about the .h .... I mean I use it all the time and it work ????
Steve is right, you shouldn't use .h with the standard C++ Library. Older compilers may ship with both fstream.h and fstream, but VS05 does not.
Before C++ got standardized, C++ headers files were still like C headers, with .h extension. But the standard C++ put all those header files under std namespace, so they rename all of them without .h extension.
|
|
|
|
|
Like I said .... " My bad " ....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
 Programm3r
|
|
|
|
|
Programm3r wrote: Cause, I don't agree with Steve about the .h .... I mean I use it all the time and it work ????
Then you don't have VS2005. The standard headers do not have .h, and the non standard headers are finally gone in VS2005.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If we hav URL how to create Inernet shortcut link to that URL programatically?
|
|
|
|
|
, Can you explain in detail ?
|
|
|
|
|
I want to copy all my favourites to some other USB Drive through programatically.
For that if i use SHFileOperation option to copy all tha favourites into my drive...The copied files are not copied as Internet shortcuts they just copied as files.
For that I retrive URLs and want to create internet shortcuts for that URLs...
Do u hav any idea regarding this favorites importing to our program ?
|
|
|
|
|
I got this code from MSDN,
#include <windows.h>
#include <shlobj.h>
#include <intshcut.h>
HRESULT CreateInternetShortcut(LPTSTR pszShortcut, LPTSTR pszURL)
{
IUniformResourceLocator *purl;
HRESULT hr;
hr = CoInitialize(NULL);
if(SUCCEEDED(hr))
{
hr = CoCreateInstance( CLSID_InternetShortcut,
NULL,
CLSCTX_INPROC_SERVER,
IID_IUniformResourceLocator,
(LPVOID*)&purl);
if(SUCCEEDED(hr))
{
IPersistFile* ppf;
hr = purl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if(SUCCEEDED(hr))
{
hr = purl->SetURL(pszURL, 0);
if(SUCCEEDED(hr))
{
WCHAR wszShortcut[MAX_PATH];
#ifdef UNICODE
lstrcpyn(wszShortcut, pszShortcut, MAX_PATH);
#else
MultiByteToWideChar( CP_ACP,
0,
pszShortcut,
-1,
wszShortcut,
MAX_PATH);
#endif
hr = ppf->Save(wszShortcut, FALSE);
}
ppf->Release();
}
purl->Release();
}
CoUninitialize();
}
return hr;
}
|
|
|
|
|
I used this code But CoCreateInstance cannot create instance in my application ,
i didn't get why it fails?
|
|
|
|
|
whats value of hr? Check if you are missing something from code. Actually it should work, as i've tested it, too.
|
|
|
|
|
the value of hr is -2147467262
|
|
|
|
|
kiranin wrote: the value of hr is -2147467262
I think its for interface not supported.
Check your system matches minimum requirement for IUniformResourceLocator . Thats all I can tell, because this code is working fine for me.
|
|
|
|