|
A vector itself cannot be passed via the command line. You can pass the data as arguments to a program. There are many classes on CodeProject for reading command line arguments.
Michael
|
|
|
|
|
Im not sure if I understand the question correct, but I suppose you could
put all arguments in a string and feed it to system() if the data consists of standard types. Otherwise you might want to serialize the data to a file and pass the file as input to the commandline..
/moliate
|
|
|
|
|
Hi.
I got some help a while back to deleting directories directly using SHFileOperation.
All works fine when I set the file name directly as "d:\...\..." in the WIN32_... variable. If I use char chFile[] = "d:\\..." it is OK too.
However, because I need to search through the directories and eliminate what I need, I tried to use sprintf and also CString to set the directory path and using this to delete the directory. It doesn't work. I think it has to do with needing a LPCTSTR which is a constant and what I am doing is not constant.
How do I get around this or how would I proceed? I am really stuck on this.
Thanks.
|
|
|
|
|
You're probably not getting the pFrom buffer right, it needs to be terminated with two zero bytes, which sprintf() does not do. Check out my SHFileOperation wrapper class in the Shell section which handles creating all the buffers for you.
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I have a regular combobox, and I want the selected item (the item shown in the editbox area of the combobox) to be automatically updated when I write something in another editbox. I also want this string to be "stored", so that next time I pull down the combobox this string is still there. So just manipulating the editbox itself isn't good enough. I also want the index to not change. I'm not using MFC, just plain Win32 API stuff.
I hope you understand what I mean :]
Sprudling
|
|
|
|
|
1. Get the index of the item that is in the edit area of your combo box with the CB_GETCURSEL message.
2. Remove this index from the combo box. That will remove this string completely. Use the CB_DELETESTRING message.
3. Get the text from your external edit box, probably with the WM_GETTEXT message.
4. Insert the new text string at the same index of the original string with the CB_INSERTSTRING message.
One more good tip it to send a WM_SETREDRAW message with false in the WPARAM field, before you even start removing and inserting the strings in the combo box, because this will make it so that the combo box does not redraw itself while you are manipulating the data.
When you are done, send a WM_SETREDRAW message with TRUE in the WPARAM field, and this will force the combo box to repaint with all of the new data.
|
|
|
|
|
Thanks, it worked
At least when I sent a CB_SETCURSEL message with the index to the combobox afterwards.
And thanks for the WM_SETREDRAW thing too
Sprudling
|
|
|
|
|
The command line in a MFC app contains the path tio the exe, but how can make my app so it doesnät contains the exe path?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Rickard Andersson wrote:
The command line in a MFC app contains the path tio the exe, but how can make my app so it doesnät contains the exe path?
What is your objective in doing that?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
It is possible to access each arg independently if you want to. They are in the variables __argc and __argv. Actually, MFC itself uses these to paste together the command line string. You must include stdlib.h to access them.
|
|
|
|
|
Nice first day of XIX Olympic Games
Can you tell me how sort items in CListCtrl by values of items in columns ? I do not know if is better use C++ function QSort() or CListCtrl::SortItems ? What is better for sorting items as is in Outlook or Explorer ?
Thank you!
Wiizi
|
|
|
|
|
Click here to find lots of things about list conyrol
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
How can I do that? the link tab is totaly different from what it used to be in vc++6
anyone can help?
|
|
|
|
|
yes,it changes a lot,but what do you want to do?
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
Or you could just use:
#pragma comment(lib, "somelibfile.lib");
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
sorry,I don't get you,
you want to add or ignore any library?
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
It's how you can link a library from code...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi,
I need to make the background color of a bitmap in my dialog transparent, but I do not want to use MFC. I would like to make my dialog totally MFC (/ATL) independant. Does anyone have a clue on how to do this?
|
|
|
|
|
If you go to www.wdj.com and look at their online article fro Sept 2001, it is on how to do transparent blitting with a colour key. The code in the article is full of memory leaks ( they ran an earlier version to the one I finally submitted ), but the code in the online archive should be OK, unless they ran the correction in the code for the issue they ran it, which was Nov or Dec from memory.
If you don't need Windows 95 support, just use TransparentBlt. I believe you'll need the SDK to do that though.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Christian,
Thanks for your reply. I downloaded the source, and extracted the method I need. But it's not exactly clear to me how this mehod works. (I have never worked with GUI stuff before). Is this the correct code, without memory leaks? Your example copies a piece of the source bitmap and places it back on another location (?) How would I just make the source bitmap transparent?
The method:
bool TransparentBltU(
HDC dcDest, // handle to Dest DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC dcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
UINT crTransparent // color to make transparent
)
{
if (nWidthDest < 1) return false;
if (nWidthSrc < 1) return false;
if (nHeightDest < 1) return false;
if (nHeightSrc < 1) return false;
HDC dc = CreateCompatibleDC(NULL);
HBITMAP bitmap = CreateBitmap(nWidthSrc, nHeightSrc, 1, GetDeviceCaps(dc, BITSPIXEL), NULL);
if (bitmap == NULL)
return false;
HBITMAP oldBitmap = (HBITMAP)SelectObject(dc, bitmap);
if (!BitBlt(dc, 0, 0, nWidthSrc, nHeightSrc, dcSrc, nXOriginSrc, nYOriginSrc, SRCCOPY))
return false;
HDC maskDC = CreateCompatibleDC(NULL);
HBITMAP maskBitmap = CreateBitmap(nWidthSrc, nHeightSrc, 1, 1, NULL);
if (maskBitmap == NULL)
return false;
HBITMAP oldMask = (HBITMAP)SelectObject(maskDC, maskBitmap);
SetBkColor(maskDC, RGB(0,0,0));
SetTextColor(maskDC, RGB(255,255,255));
if (!BitBlt(maskDC, 0,0,nWidthSrc,nHeightSrc,NULL,0,0,BLACKNESS))
return false;
SetBkColor(dc, crTransparent);
BitBlt(maskDC, 0,0,nWidthSrc,nHeightSrc,dc,0,0,SRCINVERT);
SetBkColor(dc, RGB(0,0,0));
SetTextColor(dc, RGB(255,255,255));
BitBlt(dc, 0,0,nWidthSrc,nHeightSrc,maskDC,0,0,SRCAND);
HDC newMaskDC = CreateCompatibleDC(NULL);
HBITMAP newMask;
newMask = CreateBitmap(nWidthDest, nHeightDest, 1, GetDeviceCaps(newMaskDC, BITSPIXEL), NULL);
if (newMask == NULL)
{
SelectObject(dc, oldBitmap);
DeleteDC(dc);
SelectObject(maskDC, oldMask);
DeleteDC(maskDC);
DeleteDC(newMaskDC);
return false;
}
SetStretchBltMode(newMaskDC, COLORONCOLOR);
HBITMAP oldNewMask = (HBITMAP) SelectObject(newMaskDC, newMask);
StretchBlt(newMaskDC, 0, 0, nWidthDest, nHeightDest, maskDC, 0, 0, nWidthSrc, nHeightSrc, SRCCOPY);
SelectObject(maskDC, oldMask);
DeleteDC(maskDC);
HDC newImageDC = CreateCompatibleDC(NULL);
HBITMAP newImage = CreateBitmap(nWidthDest, nHeightDest, 1, GetDeviceCaps(newMaskDC, BITSPIXEL), NULL);
if (newImage == NULL)
{
SelectObject(dc, oldBitmap);
DeleteDC(dc);
DeleteDC(newMaskDC);
return false;
}
HBITMAP oldNewImage = (HBITMAP)SelectObject(newImageDC, newImage);
StretchBlt(newImageDC, 0, 0, nWidthDest, nHeightDest, dc, 0, 0, nWidthSrc, nHeightSrc, SRCCOPY);
SelectObject(dc, oldBitmap);
DeleteDC(dc);
BitBlt( dcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, newMaskDC,
0, 0, SRCAND);
BitBlt( dcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, newImageDC,
0, 0, SRCPAINT);
SelectObject(newImageDC, oldNewImage);
DeleteDC(newImageDC);
SelectObject(newMaskDC, oldNewMask);
DeleteDC(newMaskDC);
return true;
}
|
|
|
|
|
It works because it generates a mask and uses it to do a blt that removes the transparent colour. It does a portion to be flexible.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Ok, I still do not know how to do this. If I enter the dc of my dialog image as source and destination nothing happens. What am I doing wrong?
|
|
|
|
|
The source DC contains the image to draw, the destination is where it is drawn. Just like BitBlt.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
I figured that out. But what I cannot figure out is how to actually modify the image in my dialog box. I tried to figure out the code but I just do not understand how this HDC stuff works (I don't have a good book and msdn isn't really helpfull). I tried something like this (transparent color = white):
HBITMAP hbmImg = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE );
if( hbmImg )
{
BITMAP bmInfo;
memset( &bmInfo, 0, sizeof BITMAP );
GetObject(hbmImg, sizeof BITMAP, &bmInfo);
HDC hdc = CreateCompatibleDC(NULL);
SelectObject(hdc, hbmImg);
TransparentBltU(hdc, 0,0, bmInfo.bmWidth,
bmInfo.bmHeight,hdc,0,0, bmInfo.bmWidth,
bmInfo.bmHeight, RGB(255,255,255));
}
|
|
|
|
|
I have a char vector allocated on the heap and want to test if one of the elements is equal with "\\" (simple \, but doen't I need to write \\ to tell the compiler that I mean a \, if you understand).
this is the if-statement...
if( localPath[i] == "\\" )
{
...
}
that gives me this error:
--------------------Configuration: Drag Hit - Win32 Release--------------------
Compiling...
source.cpp
C:\Program\Microsoft Visual Studio\MyProjects\Drag Hit\source.cpp(41) : error C2446: '==' : no conversion from 'char *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Program\Microsoft Visual Studio\MyProjects\Drag Hit\source.cpp(41) : error C2040: '==' : 'int' differs in levels of indirection from 'char [2]'
Error executing cl.exe.
Drag Hit.exe - 2 error(s), 0 warning(s)
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|