|
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
|
|
|
|
|
|
I am using text edit box change event to retrieve data from database.
When user types in partial text and the SQL returns only one record I would like to insert that data back to the edit text box with some modifications.
Inserting the data back generates a change event and puts the program in tailspin.
Is it possible to selectively disable the change event?
Thanks for your help.
Vaclav
-- Modified Monday, June 13, 2011 4:49 PM
|
|
|
|
|
1) Yes, if you sent a specfic format ( like only numbers) to the sql
2) The best way is to use different control to be safer side, since this will avoid problems down the road.
HTH
|
|
|
|
|
I would go for setting a flag in the auto complete function, if that's what you're doing, and checking/clearing it in the event handler.
|
|
|
|
|
Thank you Niklas,
what a simple solution. Perfect KISS!
Vaclav
|
|
|
|
|
i want to draw graph using on paint event in activex control application.
Rajesh
|
|
|
|
|
Just Create a Window derived from CCmdTarget in a OCX of your own.
And now u just have OnPaint inside it.
I hope u got the clue needed?
Величие не Бога может быть недооценена.
|
|
|
|
|
See the CIRC tutorials in MSDN. There is one for MFC and one for ATL. Both of them use WM_PAINT to paint a circle.
|
|
|
|
|
Somewhere on net I saw this code,
struct foo {
unsigned int base:19, rehash:13;
};
May I know what is significance of unsigned int base:19, rehash:13; .
Regards
|
|
|
|
|
|
|
I'm developing a win32 application with Visual Studio 2008 on Windows Vista. I specify the iron resource in the resource file:
IDI_MEXPLORER ICON DISCARDABLE "..\\resource\\icon\\mexplorer.ico"
However, I get a generic application icon on my title bar. What's weird is that it is ONLY in the title bar where I get the generic icon. In the taskbar, Windows explorer, and in the desktop shortcut, the icon is the correct one.
The code that load the icon is:
WNDCLASS wndclass;
hInst = hInstance;
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_MEXPLORER));
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = szAppName;
wndclass.lpszClassName = szAppName;
|
|
|
|
|
most often an icon file holds the same image at different sizes, and Windows chooses the one that fits its needs. Maybe your icon isn't available at the size Windows would like? I suggest you compare your current situation with other projects you did successfully.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.4
|
|
|
|
|
I can't be sure (can't test it at the moment), but shouldn't you pass the current instance to LoadIcon, since you're not loading a standard Icon but one in your executable file?
|
|
|
|
|
Hi. Lets say, we got such 2 scenarios where we are receiving data over a socket:
1. Using WSARecv
CHAR Buffer[1024];
WSABUF wsaBuffer;
DWORD dwBytesRecved = 0;
wsaBuffer.buf = (char *)Buffer;
wsaBuffer.len = sizeof(Buffer);
OVERLAPPED overLap;
::RtlSecureZeroMemory(&overLap, sizeof(overLap));
DWORD dwFlags = 0;
::WSARecv(sock, &wsaBuffer, 1, &dwBytesRecved, &dwFlags, &overLap, NULL);
wsaBuffer.buf[dwBytesRecved] = '\0';
cout << wsaBuffer.buf << ", Bytes: " << dwBytesRecved << endl;
2. And this one, using recv
CHAR Buffer[1024];
int recved = ::recv(sock, Buffer, size, 0);
Buffer[recved] = '\0';
cout << Buffer << ", Bytes: " << recved << endl;
In both cases, we are receiving only one buffer. (WSABUF allows to specify more then 1 recv buffer).
And now, in case of recv, i can do something like this:
1. i got my recv buffer size, lets say 1024 bytes and doing recv.
2. Ok, i got some data and its length is 512 bytes and it has been copied to my recv buffer. But i know, that i should receive 1024 bytes of data.
3. So i am going to recv data in a loop until all 1024 bytes arrived.
4. Ok, i got some data again and it seems like it is next 512 bytes, but this time i am calling recv like this:
int recved = ::recv(sock, Buffer + already_received_number_of_bytes, size, 0);
So the rest of received data is appended to my recv buffer and in the end my recv buffer contains all data.
The question is: how can i do this with WSARecv ?
Thanks.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Is it possible to make an application to show a modeless dialog and wait there(without executing the next statement) until the modeless dialog is closed
|
|
|
|
|
Yes, but why bother when a modal dialog does that for you.
The best things in life are not things.
|
|
|
|
|
I am having a dialog with button controls
I am invoking the same dialog from 2 places (At the first place the call is using domodal(), the second place the call is using create and showwindow)
I want to disable a few button controls when I call the dialog using domodal() but the same buttons should be enabled during the next modeless call.
kindly suggest me how to enable/disable a button when opening the dialog using domodal()
|
|
|
|