|
this works for me.
AddString adds a string to the combo box, so passing individual strings in the vector is ok.
when the user adds and remove strings in the vector, you must also add/remove strings from the combobox as well.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
you mean you got that for loop to work? Here's the error statement i get:
error C2664: 'CComboBox::AddString' : cannot convert parameter 1 from 'std::allocator<_Ty>::value_type' to 'LPCTSTR'
with
[
_Ty=std::string
]
vector<string> values;
is how im defining my vector, im passing that into a function that reads into from a text file and passes it back by reference.
i replaced 'vector.at(i)' with "hello" and that works fine. it just doesnt like my vector of strings.
how does yours work and mine doesn't.
|
|
|
|
|
this is what I did :
...
std::vector<CString> stringVector;
stringVector.push_back("allo");
stringVector.push_back("bonjour");
stringVector.push_back("salut");
stringVector.push_back("bye");
for(int i = 0; i < stringVector.size(); i++)
{
m_ComboBox.AddString(stringVector.at(i));
}
...
if using std::string you get the string with std::string::c_str()
...
std::vector<std::string> stringVector;
stringVector.push_back(std::string("allo"));
stringVector.push_back(std::string("bonjour"));
stringVector.push_back(std::string("salut"));
stringVector.push_back(std::string("bye"));
for(int i = 0; i < stringVector.size(); i++)
{
m_ComboBox.AddString(stringVector.at(i).c_str());
}
...
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
excellent, my strings weren't null terminated. heh, rinky dinky c++ code...
thanks a bunch!
|
|
|
|
|
Try that:
<br />
CString tmp;<br />
for(int i = 0; i < values.size(); i++)<br />
{<br />
tmp=(CString)values.at(i);<br />
input_tq.AddString(tmp);<br />
}<br />
|
|
|
|
|
Hello everyone...
i have a very good query.
i am writing a wizard.
there is a bitmap as usual on first page and the small bitmaps on the next pages..
The main problem is that the bitmap are seen very bad when the setting of monitor is to 256 colors.
some how i have managed to show the first bitmap(watermark) clear i mean it is working fine i can atleast see the color.But in case of the bitmap (Header)in the remainig pages i am not able to color it it looks completely black and white. i have drawn the bitmap in 256 colors so i know that the color of the bitmap should be seen fine on 256.
i have tried various ways to color the header but i am not able to do it..
any one having a knowledge can please help me out.
suggestion are also welcome..
i hope u get my problem if u dont understand u can again ask me for details
please help me out its urgent..
thanx in advance
Thanx
TAKE CARE
|
|
|
|
|
hello,
i have a problem .... a can not free memory ....
i have here 3 pointers iBuffer, jByffer, pDib
at the end of the function I want to free iBuffer and pDib
and it's get me an error when I run the program ... if I remove the "free"
lines it works fine but is not right....
what can I do ??? please if anyone can help .... thank you !
void* DDBToDIB(HBITMAP _desktopBmp, DWORD *bmpsize)
{
BYTE *iBuffer, *iBufferTmp;
int iWidth, iHeight;
void *jBuffer;
int jSize;
BITMAPINFOHEADER head;
void *pDib;
BITMAP bm;
GetObject(_desktopBmp, sizeof(BITMAP), (LPSTR) &bm);
iHeight = bm.bmHeight;
iWidth = bm.bmWidth;
DWORD dwEffWidth = ((((bm.bmBitsPixel * bm.bmWidth) + 31) / 32) * 4);
if (bm.bmBitsPixel == 8) head.biClrUsed = 256;
else head.biClrUsed = 0;
head.biSize = sizeof(BITMAPINFOHEADER);
head.biWidth = bm.bmWidth;
head.biHeight = bm.bmHeight;
head.biPlanes = 1;
head.biBitCount = (WORD)bm.bmBitsPixel;
head.biCompression = BI_RGB;
head.biSizeImage = dwEffWidth * bm.bmHeight;
head.biClrImportant = 0;
head.biXPelsPerMeter = 0;
head.biYPelsPerMeter = 0;
long mypalsize = (head.biClrUsed * sizeof(RGBQUAD));
long mysize = head.biSize + head.biSizeImage + mypalsize;
pDib = malloc(mysize);
BITMAPINFOHEADER* lpbi;
lpbi = (BITMAPINFOHEADER*)(pDib);
*lpbi = head;
iBufferTmp = ((BYTE*)pDib + *(DWORD*)pDib + mypalsize);
HDC dc = GetDC(NULL);
GetDIBits(dc, _desktopBmp, 0, iHeight, iBufferTmp, (LPBITMAPINFO)pDib, DIB_RGB_COLORS);
ReleaseDC(NULL, dc);
iBuffer = (BYTE *)malloc(iHeight * iWidth * 3);
for (int c = iHeight - 1; c >= 0; c--) {
memcpy((BYTE *)iBuffer + ((iHeight - 1 - c) * iWidth * 3),
(BYTE *)iBufferTmp + (c * iWidth * 3), iWidth * 3);
}
for (c = 0; c < iHeight * iWidth; c++) {
iBufferTmp[c * 3] = iBuffer[c * 3 + 2];
iBufferTmp[c * 3 + 1] = iBuffer[c * 3 + 1];
iBufferTmp[c * 3 + 2] = iBuffer[c * 3];
}
jBuffer = (BYTE*)Compress(iBufferTmp, iWidth, iHeight, 3, &jSize, 100);
FILE *dest = fopen("sent.jpg", "wb");
fwrite(jBuffer, jSize, 1, dest);
fclose(dest);
// free(pDib);
// free(iBuffer);
*bmpsize = jSize;
return jBuffer;
}
|
|
|
|
|
_crs_ wrote:
it's get me an error when I run the program
Such as?
_crs_ wrote:
pDib = malloc(mysize);
iBuffer = (BYTE *)malloc(iHeight * iWidth * 3);
Here, pDib and iBuffer are not being checked against NULL. While malloc() is probably not failing, it would behoove you to step through the code and see at what point either of these variables is being stepped on, since an invalid pointer passed to free() can cause errors.
|
|
|
|
|
the error is "DAMAGE: after normal block (#xx)"
and a made all pointers NULL befor malloc and the same ...
however I resolved with pDib by
lpbi = NULL; and now it works
but for iBuffer don't !
if I remove the following lines
/* for (c = 0; c < iHeight * iWidth; c++) {
iBufferTmp[c * 3] = iBuffer[c * 3 + 2];
iBufferTmp[c * 3 + 1] = iBuffer[c * 3 + 1];
iBufferTmp[c * 3 + 2] = iBuffer[c * 3];
}*/
everything works but ... I need them .....
|
|
|
|
|
If you attempt to free a block of memory after overwriting the end of its allocation, you will get the "DAMAGE: after normal block (#xx)" error.
|
|
|
|
|
Hi there,
I am examining some VC++ code that attempts to read asynchronous serial data via third party serial interface cards, namely (Moxa<4-port> and Aurora<8-port>).
When I set the baudrate to 19200 and above, then the data packets read are all fine and consistent.
But when I set the baudrate to 9600 and below then the problems start. The length and the content of the packets read are not always the same.
A packet consists of 44 bytes, with 8 bits, one start and stop bit only, no parity.
I have inserted the HasOverlappedIOCompleted() function before ReadFile() function, but to no avail.
Any help/advise would be appreciated.
Thanks
Louis
|
|
|
|
|
Try to read only 1 byte in ReadFile
|
|
|
|
|
Hi I'm trying to write a class for serial comms. One of the things I want to do is to be able to set the config of the serial port using the CommConfigDialog API call, but I keep getting an exception in serialui.dll. I think I need to call GetCommConfig first to get the pointer to the structure, but I can't work out how to get the size of the buffer (3rd parameter). Does anyone know how to do this? And also which buffer does it mean?
BOOL GetCommConfig(
HANDLE hCommDev,
LPCOMMCONFIG lpCC,
LPDWORD lpdwSize
);
Thanks
Andy
|
|
|
|
|
HANDLE hDev;
HWND hWnd;
COMMCONFIG cfg;
DWORD dwSize = sizeof(cfg);
GetCommConfig(hDev, &cfg, &dwSize);
CommConfigDialog("name of device", hWnd, &cfg);
|
|
|
|
|
Brilliant cheers
my next question is about the pointer to the window hWnd. How can I get a pointer to whichever dialogue creates an instance of my serial port class? e.g. I have a communications dialogue and I want to get a handle to this but using my serial port class, but make it flexible so that it is not restricted to one dialogue?
Thanks
Andrew
|
|
|
|
|
It would be up to the class that creates an instance of your serial port class to provide a pointer to its window. Your serial port class cannot "reach out" and get this.
|
|
|
|
|
Ok, so the Dialogue class could pass it's own pointer if I defined the interface to the config dialogue as something like
CComPort port;
port.config(hWndDialogue)
but how do I get the handle to the dialogue window? THis is what I meant really in the first place, I thought about using GetParent on the Config dialogue , but I can't because I need to create it first! Sorry if this is a stupid question. Hope you can help
Andy
|
|
|
|
|
andyg.101 wrote:
CComPort port;port.config(hWndDialogue)
but how do I get the handle to the dialogue window?
hWndDialogue IS the handle to the dialog window. I'm assuming this only because you are using a variable-naming convention where 'h' most likely means handle.
|
|
|
|
|
ok, I have worked out that I needed to use the m_hWnd member of my dialogue doh! i.e. pass
port.config(m_hWnd);
How can i find out what member variables are in a class heirarchy? The base classes viewer seems to only show functions?
Andy
|
|
|
|
|
Not sure. Are you talking about the ClassView tab in the Workspace window? I've never known it to NOT show all members of a class.
|
|
|
|
|
Yes the class view shows the members you declare in your derived class, but I don't think it shows the member variables in the base classes i.e. CWnd member variables.
Andy
|
|
|
|
|
Nor would you want it to. The Workspace window would be way too crowded then. Intellisense, however, will show you the complete list of whatever object you happen to be working on.
|
|
|
|
|
Thanks for all the help
|
|
|
|
|
Hi to all,
Is there any API to find out the current FileSystem (FAT, FAT32, NTFS) of given hard drive partition (ie. C:, D
Or any alternatives to find FileSystem ?
Thanks in Advance.
Rohit
|
|
|
|
|
check out this msdn article: click[^]
|
|
|
|