|
Sorry, I should have been more specific. Rather than general containers (some of which, you're right, have to use the find function) the map/set and the new unordered ones. They do have a member function, so could quite easily do the same thing as cbegin()/cend(), at least I can't see any reason why not.
For the not-to-const, I don't exactly follow. Gonna go play a bit to see what you mean.
Thanks,
CraigL
|
|
|
|
|
Hi, iam trying to display a browser control of type CWebBrowser2 in a dialog, which will be initiated from a dll.
now, the problem is, the dialog is getting displayed properly, when i dont insert the webbrowser control.
but when i draw the webbrowser control on the dialog, it is not showing up.
i even tried to create it dynamically, but Create method is returning by closing the application.
any ideas?
thanks in advance.
modified on Friday, June 17, 2011 5:19 PM
|
|
|
|
|
further investigations on this issue, concluded that, the window itself was not getting properly created for the web browser control. any ideas?
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
chandu004 wrote: the window itself was not getting properly created for the web browser control.
Derive your Dialog from CDialog instead of CHtmlDialog , while adding the Dialog through MFC Wizard and add a web browser control to it. Use the Navigate() method to browse to a URL.
|
|
|
|
|
after some browse through the net, i could solve this problem by adding AfxOleInit() in the calling application's InitInstance.
|
|
|
|
|
Hi,
short m_start_year;
COleDateTime tm = COleDateTime::GetCurrentTime();
m_start_year = (short) tm.GetYear();
I need to convert this m_start_year to CString to pass a argument for below function.
CString result_startdate = GetShowYear(m_start_year);
CString GetShowYear(CString m_start_year)
{
// Here i will do the Inline query and get the show start date.
}
In the above code how to cast short to CString as the GetShowYear need to pass only CString value but from tm.GetYear() i am getting as "short" value.
Any idea?
Reg,
SPa
|
|
|
|
|
Use CString::Format funcion to convert short to string like this.
CString strYear;
strYear.Format("%d", m_start_year);
http://www.mono-project.com/Main_Page
|
|
|
|
|
Simple yet very effective.
|
|
|
|
|
You cannot cast a short to a string, you need to use a converter such as sprintf() or similar.
The best things in life are not things.
|
|
|
|
|
In addition, _itoa() and similar functions are also there.
|
|
|
|
|
This code only writes the last registry entry to the ComboBox.
*I want to read all the registry entries and insert it to a ComboBox(DropDown List)*
HKEY phkResult = NULL;
LONG enumresult = 0;
TCHAR valuename[256]={0};
BYTE valuedata[4096]={0};
DWORD valuenamesize = sizeof(valuename);
DWORD valuedatasize = sizeof(valuedata);
if (RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\MY_PROG_KEY",0,KEY_READ,&phkResult) == ERROR_SUCCESS)
{
CCombo* InsCombo;
InsCombo = (CComboBox*) GetDlgItem(IDC_COMBO1);
int index = 0;
do
{
DWORD valuenamesize = sizeof(valuename);
DWORD valuedatasize = sizeof(valuedata);
enumresult=RegEnumValue(phkResult, index, valuename, &valuenamesize, 0,
NULL,
valuedata,
&valuedatasize);
m_ComboStr1=valuedata;
InsCombo->AddString(m_ComboStr1);
UpdateData(FALSE);
index ++;
m_ComboStr1='\0';
}while (enumresult != ERROR_NO_MORE_ITEMS);
RegCloseKey(phkResult);
}
<div class="modified">modified on Wednesday, June 15, 2011 5:21 AM</div>
|
|
|
|
|
It looks like you're misusing UpdateData() in the loop. Remove it, and handle such things after the loop.
|
|
|
|
|
I did that already, but after moving it outside the loop; ComboBox is not showing any string.
|
|
|
|
|
What is the definition of m_ComboStr1 ; also have you checked (with the debugger) that you are getting a valid string from RegEnumValue() ? I note also that you are redeclaring valuenamesize and valuedatasize within your do loop: this is not correct (even though it will not cause problems in this instance). Other than that the code would seem to be correct.
The best things in life are not things.
|
|
|
|
|
This piece of code as you suggested gives following error. Please Suggest.
Previous case : m_ComboStr1 is variable attached to the ComboBox (CString type)
Note: I'm new to VC++ programming.
error C2664: 'AddString' : cannot convert parameter 1 from 'unsigned char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
HKEY phkResult = NULL;
LONG enumresult = 0;
TCHAR valuename[256]={0};
BYTE valuedata[4096]={0};
DWORD valuenamesize = sizeof(valuename);
DWORD valuedatasize = sizeof(valuedata);
if (RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\MY_PROG_KEY",0,KEY_READ,&phkResult) == ERROR_SUCCESS)
{
CComboBox* InsCombo;
InsCombo = (CComboBox*) GetDlgItem(IDC_COMBO1);
int index = 0;
do
{
enumresult=RegEnumValue(phkResult, index, valuename, &valuenamesize, 0,
NULL,
valuedata,
&valuedatasize);
InsCombo->AddString(valuedata[index]);
index ++;
}while (enumresult != ERROR_NO_MORE_ITEMS);
RegCloseKey(phkResult);
}
|
|
|
|
|
Well the message is pretty clear; you are passing a character to a function that expects a string (const char* ). Try changing to something of the order of:
InsCombo->AddString(reinterpret_cast<const char*>(valuedata));
The best things in life are not things.
|
|
|
|
|
I appreciate your help.
The same code worked; as I did a silly mistake I needed to increase the drop down area
Thanks
HKEY phkResult = NULL;
LONG enumresult = 0;
TCHAR valuename[256]={0};
BYTE valuedata[4096]={0};
DWORD valuenamesize = sizeof(valuename);
DWORD valuedatasize = sizeof(valuedata);
if (RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\MY_PROG_KEY",0,KEY_READ,&phkResult) == ERROR_SUCCESS)
{
CComboBox* InsCombo;
InsCombo = (CComboBox*) GetDlgItem(IDC_COMBO1);
int index = 0;
while(RegEnumValue(phkResult, index, valuename, &valuenamesize, 0,
NULL,
valuedata,
&valuedatasize)!=ERROR_NO_MORE_ITEMS)
{
InsCombo->AddString(reinterpret_cast<const char*>(valuedata));
index ++;
}
}
RegCloseKey(phkResult);
return TRUE;
modified on Wednesday, June 15, 2011 5:20 AM
|
|
|
|
|
Gaurav Paul wrote: InsCombo->AddString(reinterpret_cast<const char*>(valuedata[index]));
You should not be using an offset value (valuedata[index] ) but merely the address of the array (valuedata ) as shown in my previous post.
The best things in life are not things.
|
|
|
|
|
I have done that; actually I posted the old code.
|
|
|
|
|
Am I to assume it is now working successfully?
The best things in life are not things.
|
|
|
|
|
Yes it is! Thanks.
|
|
|
|
|
gaurav.paul wrote: UpdateData(FALSE); I wouldn't go any further until this was removed.
gaurav.paul wrote: m_ComboStr1=valuedata; Why the extra variable? AddString() can be called with valuedata .
gaurav.paul wrote: InsCombo->AddString(m_ComboStr1); What is this returning?
gaurav.paul wrote: m_ComboStr1='\0'; What's the purpose of this? It's unnecessary.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
This piece of code as you suggested gives following error. Please Suggest.
Previous case : m_ComboStr1 is variable attached to the ComboBox (CString type)
Note: I'm new to VC++ programming.
error C2664: 'AddString' : cannot convert parameter 1 from 'unsigned char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
HKEY phkResult = NULL;
LONG enumresult = 0;
TCHAR valuename[256]={0};
BYTE valuedata[4096]={0};
DWORD valuenamesize = sizeof(valuename);
DWORD valuedatasize = sizeof(valuedata);
if (RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\MY_PROG_KEY",0,KEY_READ,&phkResult) == ERROR_SUCCESS)
{
CComboBox* InsCombo;
InsCombo = (CComboBox*) GetDlgItem(IDC_COMBO1);
int index = 0;
do
{
enumresult=RegEnumValue(phkResult, index, valuename, &valuenamesize, 0,
NULL,
valuedata,
&valuedatasize);
InsCombo->AddString(valuedata[index]);
index ++;
}while (enumresult != ERROR_NO_MORE_ITEMS);
RegCloseKey(phkResult);
}
|
|
|
|
|
Gaurav Paul wrote: InsCombo->AddString(valuedata[index]); This is not what I suggested. Use:
InsCombo->AddString(valuedata);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|