|
It seems you misunderstood the non-flag term. With
app.exe /myFlag anotherfile.txt
myFlag is a flag and anotherfile.txt is a non-flagged parameter.
To use values with flags, one option is to separate the value using the assignment character without any spaces:
app.exe /myFlag=anotherfile.txt
Your parser must then extract the value.
If you want to use space separated values, you may add member variables to your CCommandLineInfo derived class storing the flag if it has required or optional values. With the next call to ParseParam , you can then get the value.
|
|
|
|
|
Hello,
I've created a button that displays a CBitmap, and switches to a different bitmap when pressed.
I now want to add transparency, allowing the dialog background to show through in certain places.
To do this, I have set a background image on the dialog by overriding the OnEraseBkgnd() method.
The button draw code is called from the dialog OnDrawItem. The drawing code then updates the buttons pCwnd DC (obtained from GetDlgItem, GetDC).
- The DC creates a compatible DC from realDC.
- The DC select-object's a bitmap (realDC compatiblebitmap)
- TransparentBlt a bitmap to the DC
- BitBlt the DC to the realDC
For non-transparent buttons, the above works fine. When there is transparency in the button image, the background doesnt show. Instead, there are smears, or a portion of the previous bitmap remains (when changing from non-transparent to transparent when it is clicked).
I thought I needed an 'Invalidate(TRUE)', not really sure. I tried calling it but it just refreshes the transparent portion to whatever it was before (generally a black/white smear).
Can anyone see any issues with the steps I mentioned above?
TIA.
[EDIT] Using MFC on WinCE.
|
|
|
|
|
Step1. Blit the background bitmap on the realDC.
Step2. Create a bitmap that is compatible with realDC
Step3. Draw on the compatible bitmap (transparent blit)
Step4. Blit this bitmap onto the realDC.
Why would you expect to have th ebackground bitmap magically appear on the compatible bitmap? This should be something like:
Step1. Blit the background bitmap on the realDC.
Step2. Create a bitmap that is compatible with realDC
Step3. Blit the correct portion of the background bitmap onto the compatible bitmap.
Step4. Draw on the compatible bitmap (transparent blit)
Step5. Blit this bitmap onto the realDC.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
modified 2-Apr-12 11:55am.
|
|
|
|
|
Not sure to be honest. I just assumed TransparentBlt contained magic!
What is the 'correct' way to retrieve the background? Using what I know, I guess I could use a variation of the OnEraseBkgnd() code (ie load resource, StretchBlt to temporary DC, then BitBlt to the compatible bitmap) - but I suspect that is not very efficient. Is it possible to retrieve it from the 'realDC'?
Thanks for your help!
|
|
|
|
|
Transparent blt basically works something like this:
take the pixel of the source surface (e.g. a bitmap in memory), check if its color equals the 'transparent color', if no, draw it onto the target and move on to the next pixel, if yes, skip it and move on to the next pixel.
I don't think there is a "correct way by the book" to do it, what you said about invoking OnEraseBkgnd is one way, you could also try to store the part of the background bitmap in memory which lies under your button and use that when drawing.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
That did the trick - thanks!
I'll probably store the entire bitmap in memory, as there are multiple buttons and dialogs that will use it.
|
|
|
|
|
Yourwelcome, glad it worked out. Good luck with the rest.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
vector<int> vect;
vector<int>::iterator pBegin;
I want to check the iterator for NULL.
In VC6 we can compare if (pBegin == NULL) and it works. But in VC10 we cannot compare iterator to NULL.
How to achieve that in VC10?
|
|
|
|
|
You should check against begin or end (usually past the end ).
if you have
KASR1 wrote: vector<int>::iterator pBegin;
Than it should be treated as an uninitialized variable, so it it give out bad results if used as-is.
As far as I know, the STL implementation in VC6 is crap and not standard.
Watched code never compiles.
|
|
|
|
|
Ok. Lets assume its not initialized.
Can we consider checking
if (pBegin != vect.end()) in place of if( pBegin != NULL)
|
|
|
|
|
You need to assign the iterator to something valid before using it.
std::vector<int> v;
std::vector<int>::iterator pBegin = v.begin();
while ( pBegin != v.end() )
{
++it;
}
or
if ( pBegin != v.end() )
{
}
Watched code never compiles.
|
|
|
|
|
|
std::vector<int>::iterator pIter = v.end();
//do Some operation on pIter
if ( pIter != v.end() )
{
// do something
}
Is the above logic make sense?
|
|
|
|
|
Checking it against NULL is wrong. It's an implementation detail that it works in vc6 (because raw pointers are used, amongst other implementation specific details). Iterators are not required be pointers, in fact vectors are one of the few containers where they can do the job and as you've discovered even then they are not the only option.
Steve
|
|
|
|
|
Hi all,
I want to map logical drive to its physical drive value i.e. if i give c: it should tell its hard disk number and partition number. For example if i give C: it should give \Device\HardDiskVolume1. For doing so i have used QueryDosDevice but it is not giving me correct answer. Here is my code
CString text;
GetDlgItemText(IDC_EDIT1,text);
TCHAR szBuffer[MAX_PATH];
bool bIsFloppy = false;
if (QueryDosDevice(text, szBuffer, MAX_PATH) > 0)
{
CString buffer = szBuffer;
AfxMessageBox(buffer);
}
But my code is giving incorrect result \Device\HardDiskVolume11
Can anybody please tell me what i am doing wrong?
|
|
|
|
|
Your code is not incorrect; volume names are assigned internally by Windows and do not necessarily follow the order that you expect. There is lots of information in MSDN here[^] that helps to explain it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
there are a struct:
struct _Tag
{
Type a;
Type b;
};
I just want to set the the type of a and b at runtime(i.e. set a to int and later set a to string within the same struct _Tag), don't tell me to use templates. For templates don't meet my requirements.
Another question:
There is a C++ statement:
AfxMessageBox(_T("Hello, world!")) ;
what I want to do is put the statement above into a
CString variable str . That is:
CString str = _T("AfxMessageBox(_T(\"Hello, world!\"));");
I want to execute the statement stored in str later, so that the statement just like the ACTUAL MFC EXECUTABLE STATEMENT I typed.
I wonder whether C++ support such operations.
Any help will be appreciated!
|
|
|
|
|
|
Thanks for reply!
You solved my first question.
But how about the second question?
|
|
|
|
|
Falconapollo wrote: I wonder whether C++ support such operations.
Nope, there is NO support for such operations. You have to build yourself a parser or embed a script engine in your application (for instance you may host, via <code> COM, VBScipt or JScript : have a look ath the following, bit dated, Codeproject article "Adding VBScript and JScript support in your C++ applications"[^]. Another nice option is Lua[^]).
Veni, vidi, vici.
|
|
|
|
|
1) Use a union.
2) You cant compile code at run time. What you can do is use function pointers so you can select the behaviour you want at run time.
==============================
Nothing to say.
|
|
|
|
|
I have developed one GUI in vb.net but now I want to use C as backend code along with MySql as database.
Is it possible to create such a application.
I have been using C and MySql under Fedora and I have my GUI ready in vb.net. Can you tell me how can I communicate these thing together?
For ex. I have add button on front end, when I click add button, and instead of defining functionality in vb.net I want to send input to C function and then C function will execute and return output.
|
|
|
|
|
Do you mean that you want the VB frontend running under windows to "do business" on a -most likely separate- machine running Fedora? If yes, i'd say, use a client-server aproach, run a server on the Fedora machine onto which your VB app connects and then sends commands (which are then executed by your C code) and receives results (created by your C code).
If you mean that you want the C code to also run on the windows machine, in my oppinion your best bet would be to create a DLL from your C code and then use it in a VB app with your frontend calling methods as needed.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Yes I want to use first approach means I will use client-server approach. But can you tell me how can I do this?
|
|
|
|
|
Look into sockets under linux[^] and sockets under windows[^], i'd use TCP/IP or UDP depending on your needs. For VB related questions, target the VB forums here on CodeProject.
For the basic client-server aproach[^], Google is your friend.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|