|
First off, what you are creating is a rebar control. This rebar control has two bands. First band is a menu bar control, and the second band is a combobox control.
Note that a menu bar control is NOT a CMenu object. MFC does not directly support a menu bar (as far as I remember), so you must design one yourself. A menu bar, basically, is a toolbar with a collection of text-only buttons. When clicking on a button, a pop-up menu is launched. This menu can be loaded from a resource, just like a normal pop-up menu would be.
To create a menu bar object, follow the implementation sample from MSDN here[^].
After this, create a CReBar control. From the frame window, remove the menu. Instead, add the CReBar, add the newly created menu bar control, and add the combo box control. You can add more controls if you want to. Then add the CReBar control into the frame window. Voila, you're done.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
Note that a menu bar control is NOT a CMenu object. MFC does not directly support a menu bar (as far as I remember), so you must design one yourself.
that's it. any "movable" menus also are not CMenu s...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I now can obtain a pointer points to the place where a bitmap stored in the memory, but I'm wandering how to display it on a dialogue based programme.
Thank you for your attention.
the simplier the better!
|
|
|
|
|
Select the bitmap into a new device context, (must be compatible, CreateCompatibleDC() does this);
then just CDC->BitBlt(); on the OnPaint() proc of the dialog app
|
|
|
|
|
rw104,thank you for your instructions, but I want to display the bitmap on a dialogue, so can you give me some more delights.
the simplier the better!
|
|
|
|
|
CDC imgDC;//temp CDC to render the bitmap into
imgDC.CreateCompatibleDC(pdc); //pdc is the standard screen dialog CDC, imgDC needs to be compat..
CBitmap yourBitmap;
yourBitmap.LoadBitmap(IDB_RESOURCEIMAGE);
//IDB_RESOURCEIMAGE is an image resource
//You already have a pointer to a bitmap so you do not need these two lines.
imgDC.SelectObject(yourBitmap);//bitmap gets selected into the dc
//bitblt the image , you 'll need to decide co-ordiantes
pdc->BitBlt(0,0,100,100,&imgDC,0,0,SRCCOPY);
That's it;P
|
|
|
|
|
There have been articles on transparent windows. In these cases, the topmost window is given varying degrees of transparency so the lower window is still visible. However, is it possible to add an overlay, something like a corporate logo for instance, that would do nothing but show the logo covering the screen. All controls and data entry would be at one or more of the lower-level windows. If the logo screenshot goes behind bacause the active window is pulled up, the effect is lost so I would want to avoid that. If a new window is popped up, I would still want the overlay remaining on top. The overlay kind of just sits on top, pretty much like you pasted a transparecy on the face of the monitor.
If the logo is the first one to be painted on the screen, all other windows would have to be made transparent, which might be difficult and multiple windows at 80% transparency does lead to opacity at some point.
Is there any way to accomplish what I want?
Thanks.
|
|
|
|
|
I have some codes that print some words, lines and a bitmap to the printer. But everything printed fine except the bitmap even it works fine in print preview.
Can you help me?
Thanks
|
|
|
|
|
What's the problem ? Is the bitmap really tiny ? If so, you need to get the size of the printer DC and stretchblt your image onto it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
No, the image size is ok and the print preview works quite well, but it did not appear on the actual paper (bitmap lost).
|
|
|
|
|
What`s the code? What`s the problem? You couldn`t use the same CDC for printing bitmap with the CDC for printing lines and words.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
I expect that the bitmap is tiny on the print out? is this what is happening?
if so it is because you are drawing the bitmap into a printing device context, in which case a much higher resolution is used, you need to use the CDC function
StretchBlt() to draw the bitmap into a resolution equivalent rectangle which you will need to work out. So look up StretchBlt()on MSDN its is very simple.!! this
function simply stretches the bits in the bitmap accordingly.
Print preview probably works because it uses a screen DC just like what you are drawing on.
P.S. I hope this is the problem you are getting, if not soz!!
|
|
|
|
|
Soz!,other replies were not there when I replied, Im just not quick enough, well I was eating lunch!!
|
|
|
|
|
I do use the StretchBlt to copy bitmap from memory dc to the actual dc I got from CPrintDlg::CreateDC(), I think may be the problem is the image I want to print is colored, and the device is just only a black-white printer.
|
|
|
|
|
Hi,
I thought this was solved but there happens to be so mnay ways in which these two functions can fail
Here is the scenerio.
I need to connect to the server to find out if winzip command line utilities are installed or not. I use brute force method of connecting to the server running a dummy command using CreateProcess to run the command like c:\progra~1\winzip\wzzip.exe file.zip file.txt (assume file.txt exist).
It turns out to be faster than checking for presence of exes and dependencies.
It works like charm most of the times accept for one scenerio.
This deals with connection problems rather than createprocess etc.
I can do that only if I have valid access to drive c: on server to run the wzzip.exe.
So, I use WNetAddConnection2 to connect to the \\servername\c$ with proper administrative rights ( administrative usernames and password to the server, server is on LAN). After completing processing I dc using WNetCancelConnection2 .
The problem is if i go to winexplorer type in \\servername\c$, it prompts me for username and password. I enter the info and do what i do on c: of server and close the explorer. Now somehow windows remeber this connection and even a call to WNetCancelConnection2 fails to delete it. So when i call WNetAddConnection2 it returns the erro saying the credentials provided conflict with existing crediantls. But if i restart the computer and then run the app it conencts fine and do what it is suposed to do.
Is there a way I can make windows forget the connection (it's not even mapped ).
WNetCancelConnection2 is supposed to delete all non persistent conenctions liekt his, but It does not seem to be doing so.
Does anyone has an idea what's going on here???
Thankyou in advance
P.S. :can provide sample code, thought should explain teh scenerio first.
|
|
|
|
|
A clip from an older project. Deletes all connections. Modify to suite your needs.
Hope this helps.
/+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
// DeleteAllConnections()
// Purpose: Delete all network connections
// Added : 4/06/04
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
void TestDlg::DeleteAllConnections()
{
DWORD dwResult;
HANDLE hEnum;
DWORD cbBuffer = 16384;
DWORD cEntries = 0xFFFFFFFF;
LPNETRESOURCE lpnrDrv;
#if _DEBUG
return;
#endif
dwResult = WNetOpenEnum( RESOURCE_CONNECTED, RESOURCETYPE_ANY,0,NULL,&hEnum );
if (dwResult != NO_ERROR)
{
GetErrorMsg(dwResult);
return;
}
// start enumerating all the connections
while( dwResult != ERROR_NO_MORE_ITEMS )
{
lpnrDrv = (LPNETRESOURCE) GlobalAlloc( GPTR, cbBuffer );
dwResult = WNetEnumResource( hEnum, &cEntries, lpnrDrv, &cbBuffer);
if (dwResult == NO_ERROR)
{
for( DWORD ii = 0; ii < cEntries; ii++ )
{
if( lpnrDrv[ii].lpLocalName != NULL )
dwResult=WNetCancelConnection(lpnrDrv[ii].lpLocalName, TRUE );
else
dwResult=WNetCancelConnection(lpnrDrv[ii].lpRemoteName,TRUE );
GetErrorMsg(dwResult);
}
}
}
// cleanup
GlobalFree( (HGLOBAL) lpnrDrv );
WNetCloseEnum(hEnum);
}
Erik
|
|
|
|
|
Ok this is a just a remake of the piece of source that has the problem..
char somthing[200];
char somthing2[200];
cin>>somthing;
cin>>somthing2;
cout<
|
|
|
|
|
Works for me. the only thing is that because you are not outputting newlines the output was "hellohi", as expected.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Given the following:
string Part = “*(-2)”
char buf[5] = “10”
string Result = buf after arithmetic defined in Part is performed
I need to isolate the value after “-“ in Part and perform the arithmetic on buf (knowing in advance that this is a subtraction): For example, using the string values above (pseudo-code):
1- Isolate the “2” in string Part
[actually isolate everything between the “-“ and “)”]
2- Perform the subtraction buf – 2
3- Store result in Result string
Therefore the result should be Result = 8 (10 – 2 = 8)
I need a way to perform these steps….
Any clues or help would be greatly appreciated.
Thanks,
|
|
|
|
|
|
[actually isolate everything between the “-“ and “)”]
If this is exactly what you want, and you don't expect variations, then the following should do:
int x;
sscanf(Part.c_str(),"*(-%d",&x);
But if you wish your program to handle reasonably arbitrary arithmetic expressions the task is not that easy, you'll be basically building an expression parser.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Given string Part = “*(X2)” [multiplication]
I use the following code to extract the “2” into integer arith:
scanf(Part.c_str(),"*(X%d",&arith);
For the addition [“*(+2)”] and subtraction [“*(-2)”] this works perfectly.
However with the multiplication [“*(X2)”] arith is evaluated to be 0 instead of the expected “2”. I also tried using Part = “*(*2)” [this was my first choice] and it does the same thing. Any clues or recommendation?
The exact same problem occurs when trying to implement the Divide [Part = “*(|2)”].
Arith is evaluated to be 0 instead of the expected 2.
Why does it only work for my add [+] and subtract [-] and not my multiply [*] and divide [|]?
|
|
|
|
|
I am trying to always print in Landscape mode regardless of what user chooses. This is my code:
PRINTDLG pd;
LPDEVMODE pDevMode;
pDevMode=NULL;
pDevMode = (LPDEVMODE)::GlobalLock(pd.hDevMode);
// set orientation to landscape
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
pd.hDevMode = pDevMode;//Not needed
::GlobalUnlock(pd.hDevMode);
But it is not working. It always prints whatever user sets in PRINTDLG.
Any help will be appreciated.
Thanks to all.
Joe,
|
|
|
|
|
First off, this is a bad idea. If you want to always print in landscape then you are better off using a custom template and removing the portrait/landscape option from the dialog. Your users will get very PO'd if they choose portrait and it comes out landscape.
Now for your problem: Where have you inserted this code, because I do not see where you call the PrintDlg function. You should set the orientation to what you want after the dialog has been called and returned, if you call it before, then the dialog will override whatever settings you set.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks for repsonding.
I did call it right after it had returned:
memset( &pd, 0, sizeof(PRINTDLG) );
// other init stuff
//then
if( !PrintDlg(&pd)) return 1;
// then I had here that code here...
// landscape mode .. etc
Joe,
|
|
|
|