|
THanks for the reply.
Actually I'm not that good in VC++. Could you please send some examples?
Thanks.
|
|
|
|
|
Sorry, don't have any examples.
Here is an idea:
HWND hSnapShotWnd = ??; // This is the window for the snapshot (IE)
//create memory dc:
HDC hWinDC = GetDC(NULL);
hDC hMemDC = CreateCompatibleDC(hWinDC);
RECT rcClient;
GetClientRect(hSnapShotWnd , rcClient);
//create bitmap for the snapshot of the client area of the window
HBITMAP hBitmap = CreateCompatibleBitmap(hWinDC, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
HBITMAP hOld = SelectObject(hMemDC, hBitmap);
SendMessage(hSnapShotWnd, WM_PRINTCLIENT, (WAPRAM)hMemDC, PRF_ERASEBKGND|PRF_CLIENT|PRF_CHILDREN);
//after that hBitmap contains the picture of the client area of the hSnapShotWnd (if window supports WM_PRINTCLIENT).
SelectObject(hMemDC, hOld);
DeleteDC(hWinDC);
DeleteDC(hMemDC);
HTH,
Edward
|
|
|
|
|
Hello everyone, I just wanted to know how to create a dailog program that would call another dialog. I have looked at the articles supplied at the site, which are very good, but have not seen a simple example. Most of them are just to complex for me to understand since i have just started programming in mfc. I was wondering if anyone know a simple skelaton example where a dialog based mfc program calls another dailog.
My main problem is not creating the second dialog or the main dialog but its how to declare it in the main dialog, and just the technical stuff.
Thank you.
|
|
|
|
|
You'll need two dialoog templates in the project's .rc file. You'll also need two CDialog -derived classes (e.g., DialogA, DialogB), one for each template. Use ClassWizard to create these. In the OnInitDialog() method of DialogA, create an instance of DialogB and call its DoModal() method. Something like:
BOOL DialogA::OnInitDialog()
{
DialogB B;
B.DoModal();
return TRUE;
}
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Not sure if the other post helps, but I'll try and break it down. Basically you are going to add a new dialog resource. Call it what ever you want for the window title. After you add your new dialog resource, the easiest thing is to open Class wizard. It will ask you if you wish to add this to an existing class or make a new one. Choose make a new one. Then here you will be given a chance to create your class for this dialog as well as the .CPP and .H files (you'll see what I'm talking about when you get there). Now in your main program add the newly created header file. Then create a reference to that class. Lastly, to open that new dialog just do a DoModal and there you are.
Hope this gets you going. From there you can find tons of ideas as to what you can do.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Well, I have my string, let's say
LPSTR myString = "up?";
I'd want to add " Whats " in front of it, just like
LPSTR myString = "up?";<br />
myString = "Whats " + myString;
I get an error.
Then I tried doing:
<br />
LPSTR myString = "up?";<br />
sprintf(myString,"Whats %s",myString);<br />
This also doesn't work.
Any help please?
Thanks
~Mike
|
|
|
|
|
You have to understand that an LPSTR is a very primitive thing: a pointer to an array of characters that is supposed to have a \0 on the end. You can do operations with LPSTR (look at the strcat function) but you have to make sure that you have allocated another array to hold the result that is large enough. Manipulating strings this way has been done for years in C and has led to innumerable buffer overflow errors. You should never do it in C++. You should use the string classes (std::string, std::wstring for wide characters) that are in the standard library, which take care of buffer allocation (and many other useful things) for you. You can concatenate std::string with the overloaded + operator and get just what you expect.
|
|
|
|
|
this seemed to work:
#include <iostream.h>
#include <string.h>
#include <windows.h>
LPSTR concat(LPSTR s1, LPSTR s2)
{
char* str = new char[strlen(s1) + strlen(s2) + 1];
LPSTR final_str = str;
strcpy(str, s1);
strcat(str, s2);
return final_str;
}
int main()
{
LPSTR s1 = "this is a";
LPSTR s2 = " test.";
cout << concat(s1, s2) << endl;
return 0;
}
|
|
|
|
|
Quick answer: C-style strings don't work like that.
Long answer: See the above replies for some code that does what you want, although you must learn how C-style strings work in order to use the strcat /strcpy functions properly. The std::string class is much easier to learn and use if you don't absolutely need a C-style string.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
it is wrong certainly.because your "myString" points to a static data area,which can not be changed.so ,your "myString = "Whats " + myString" is wrong.you must do so:
char str[10]="up?";
char mystring[20];
sprintf(mystring,"Whats %s",str);
|
|
|
|
|
Hi all,
I have an app that must implement window (f1) and context level (shift+f1) help. Conext level help is a problem.
There does not seem to be any methods available to so that i can be nofified when shift+f1 is pressed . If none are available then the only solution is to add an entry in the accelerator table. However, then I need someway to get a handle to the currently focused component (so i know what context help to show). I am not sure how to do this either!
any help appreciated...
brian.
|
|
|
|
|
Two questions here. Question the first: I have a dialog app and on it I have a group box with a radio button over it's heading. The reason I'm doing this is because I want it to enable the controls in the groupbox when the radio is pressed, and I'd like it to look like the radio and groupbox are one control. The problem I'm encoutering is that the radio always appears "behind" the groupbox so there is a line through it. When the radio is clicked it's drawn properly so the first thing I tried doing is setting the focus to it when the dialog was enabled, that didn't really work. So my question is how would I get the radio to show on top of the groupbox?
Question the second: I saw a post on here a couple days ago with what appeared to be a similar question and the person was directed to look at WS_CLIPSIBLINGS so I did that as well. It seems like that's what I want so I tried this code to change the style of that radio button:
HWND hStyle = GetDlgItem (IDC_CLOSED_IN_RANGE_CLEC)->GetSafeHwnd ();
LONG lStyle = ::GetWindowLong (hStyle, GWL_STYLE);
lStyle |= WS_CLIPSIBLINGS;
::SetWindowLong (hStyle, GWL_STYLE, lStyle); It didn't work so really my second question is is WS_CLIPSIBLINGS the right thing for what I want and is that code above even close to how the style of a window should be changed?
Any and all help is appreciated.
- Aaron
|
|
|
|
|
1. Do you mean a radio button, or a checkbox?
2. Probably, yes. That code should do what you want, assuming that the IDC is that of your radio button.
In the tab order, is the radio button earlier(lower) or later(higher) than the group box?
(in VC++6 IDE, use ctl-D to display tab order numbers)
If all else fails, synthesis a groupbox with lines. It's an old trick, but it might just work....
Steve S
|
|
|
|
|
I mean radio button (it makes sense in the context of the program).
I'm pretty sure that's the IDC of the button, but I'll double check. I'll also check the tab order, if it was earlier(lower) should it be on top?
I'd prefer not to "synthesis" the groupbox, but thanks for the tip if nothing else works.
- Aaron
|
|
|
|
|
|
I'll check those out. Thanks.
- Aaron
|
|
|
|
|
|
Hello there,
I wrote some applications and since a lot of these applications use common classes I figured I`ld put the common classes and code in a dll and load the dll in the apps. That way my executables would be smaller and my projects would have a better overview (less files).
The following I noticed however:
when including a certain class in my dll that required me to link to a lib the dll file increased with 150kB, but including the class in my app and linking to the lib increased the exe with only 80kB.
How does it come that the same code (except for dllexport) results in so much more memory in a dll compared to a exe?
Thanks to anyone that might shed some light on this...
|
|
|
|
|
When you are making an EXE, the linker knows your one exported function main is the top of
the dependency tree. If you don't call a function, and none of the functions you call call the
function (even indirectly), then it is thrown away. This includes functions in the EXE you wrote.
When you write a DLL, you have a lot of "tree tops", all of which may be called by another EXE / DLL.
So the linker cannot cull dead code, as it may be called.
Did that make sense to you?
Iain.
|
|
|
|
|
Yeah I did to me
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
It makes sense.. Thanks for the answer, I`ll just have to look now when to put something in the dll and when it might not be the best solution... Because size matters in my apps.
thx again...
|
|
|
|
|
Hai friends
I have problem while GIF decoding . What i do when a code is
coming which not in translation table ?. Can i output previous code or current code ? . what will i add to the translation table ?.
Please Help me
Thanks in Advance
by Krishandevan
krishnadevan@ushusteh.com
If anu useful site found please inform me friends
Its Urgent
krishnadk
|
|
|
|
|
I want to write a program with MFC to read and write to Ms Excel and Access.
How can I do it?
Mehdi Hosseinpour
|
|
|
|
|
Search MSDN for articles on Excel (OLE) Automation.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi all
i use the following piece of code to call an external program, however
i keep getting a warning message returned back which i compile
im using VS2003
the code is
HINSTANCE ok = ShellExecute(NULL, "open", "Update.exe", "NewUpdate", NULL, SW_SHOW);
if ((int)ok > 32)
{
AddToLog("Program run sucessfully",0);
}
else
{
AddToLog("Program failed to run ",0);
}
and the warning message i get back is
(1467): warning C4311: 'type cast' : pointer truncation from 'HINSTANCE' to 'int'
does ne1 have any ideas ??
thanks
si
|
|
|
|