|
// Something like this will get you to the next step...
CBitmap bmp;
CDC memDC;
CClientDC dc(this); // Will clean itself up when goes out of scope
memDC.CreateCompatibleDC(&dc);
bmp.CreateCompatibleBitmap(&dc,1000,2000);
memDC.SelectObject(&bmp);
// Add error checking, etc...
// NOTE: The CClientDC is not needed if in OnDraw
|
|
|
|
|
Thanks!
I find the problem, the parameter w that used in function CreateCompatibleBitmap(m_memDC->m_hDC, w, h) is too big, I set default value is 65535, because msdn say this parameter is a int.
It's a puzzle why I can not set the max value to this parameter, may be it out off CDC's default allocable memory.
??
-- modified at 1:00 Saturday 10th June, 2006
|
|
|
|
|
Our app creates a main dialog window and uses SetIcon to set the taskbar icon. That works fine. Then that window creates another modeless dialog and it too uses SetIcon. The taskbar then groups the two icons, but the icon it uses is directly from the app's resource file (IDR_MAINFRAME). How can I set that (group) icon too? Interestingly I remvoed the IDR_MAINFRAME icon def from the resource file and I get a black square for the taskbar group icon!! (actually the black square only resulted after I used TweakUI to clean out the cached icons -- windows is just sooo frustrating)
Thanks for any hints on this very (typically) frustrating mfc/windows behavior!!
Jeremy
|
|
|
|
|
If your using VC++ 6.0, messing with the Resource files directly can sometimes get you some interesting artifacts on the dialogs that can be undone but it takes some trial and error jacking around. Just make sure to copy the project before making direct modifications to those resource files. My favorite artifact is the blue line mish-mash pattern.
|
|
|
|
|
Dear all;
I am trying to make some drawings on a dialog based application. As far as i have understood, its better to place a Static control and draw on it instead of directly drawing on top of the dialog.
As i am trying to achieve this, i am a little bit confused and gona be needing some of your help.
I have added a picture control to my dialog and created a member variable for it of type CStatic. Now I need to subclass the picture control in which i will be overriding the OnPaint() function. I do not know how to perform this subclassing ?
Thanx
llp00na
|
|
|
|
|
I wouldn't add a picture control, I'd add a static control and subclass that. But you have to specify that you want to receive messages by adding 'SS_NOTIFY' (or something like that) to the window's style. have a look here at my Modeler[^]
My Music | My Pics | My Articles
BlackDice
|
|
|
|
|
Greetings:
I'm developing a project under Visual Studio 2003. It's an MFC C++ project using the SDI framework.
I have just created a simple dialog box under the resource editor (I already have lots of dialogs). I gave the dialog a resource name "IDD_WHATEVER_DLG" and then double clicked the dialog to launch Class Wizard. I get the Class Wizard window and I specify that I want a simple CDialog derived dialog. I fill in the class name input and click "Finish".
Nothing happens. I don't get an error message of any kind. The Class Wizard input box closes, but I look through my project directory and it does not seem to have created the class files.
I have closed VS and restarted it. I have checked to ensure that none of my project files are READ-ONLY. I have plenty of hard drive space. I have deleted the ASP file and reloaded the project. I have sacrificed a chicken and tried again repeatedly. Same result every time.
Does anybody know what the problem might be?
Thanks in advance!
Mark
|
|
|
|
|
With the project closed...
Try the old "delete the .ncb file to make my classes reappear" trick that works all too well on VC++ 6.0. I'm not sure I've encountered it yet on VC++ 2003 but my intellisense "out to lunch" error still happens on 2003 and the .ncb trick "sometimes" fixes it.
For what it's worth
|
|
|
|
|
Hi ,
I have written a cgi script using C++, which it is going to be executed on a web browser. I was trying to do a "system()" command in cgi script to open another URL in the same browser. I was able to execute the cgi script calling the "system()" command successfully at the command line, but I had a problem when cgi script is on the web browser. Is this a permission problem? Or maybe there is another way to call an URL in the same browser from the cgi script?
Thank you ,
Lynniz
|
|
|
|
|
Lynniz wrote: I was trying to do a "system()" command...
Why use this antiquated function when ShellExecute() exists?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Does ShellExecute()work with Linux? I thought this was for Windows only.
Thank you,
Lynniz
|
|
|
|
|
I don't know. You are, however, on a VC++ forum so Windows is implied.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Lynniz wrote: I have written a cgi script using C++, which it is going to be executed on a web browser.
Not sure what are you really trying to do, but cgi scripts are executed on a server, not on a web browser.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
This is what I have right now:
I have made a HTML page that contains an image map and a form. When I click on the image map, it is going to pass the coordinates of the clicked point to a cgi script. The cgi script is used here to parse the string and get the coordinate values and update the the original HTML page with the new coordinate values filled in in the form.
What I did in the cgi script was I made a copy of the orginial HTML page and saved it under a different name. After parsing the string and get the new coordinate values, I open up the new HTML as a text file and go in to update the form with new coordinate values. After I am done with that, I am trying to open the new HTML page in the same browser where the original HTML page is at. So this way it looks like to the viewer that the original HTML is beind updated. That is why I was trying to use a system command to call the new HTML page. I was able to call the new HTML page on the commandline, but I wasn't able to call it when I am using the server to execute the cgi script. Last thing, this is in a Linux enviroment.
I am probably doing it the harder way. Does this sounds more clear to you?
Thank you.
-- modified at 7:52 Monday 12th June, 2006
|
|
|
|
|
A graph was drawn using a CDC on a class derived from CWnd. This was done in OnPaint(). I want to clear this graph when the user presses a button. What code do I ned in the button press?
thanks,
sb
|
|
|
|
|
You don't clear the CDC, you just 'ask' for a repaint, that will erase everything. You can call Invalidate() for that.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Cedric Moonen wrote:
just 'ask' for a repaint, that will erase everything
We all know what you meant but what you typed is a different story
I'm just reading it from the thread issuer's view and if they take you literally, they'll just call Invalidate() in their button pressed handler which will ultimately generate the call to the OnDraw which drew the graph in the first place effectively redrawing it once again.
I'm guessing what you meant to say was in the button pressed handler, set some member variable to false like...
// declaration
BOOL m_bDrawGraph;
// constuctor
m_bDrawGraph=TRUE;
// On button pressed handler
m_bDrawGraph=FALSE;
Invalidate();
// OnDraw
if (m_bDrawGraph) {
// Draw the graph, etc...
} else {
// OnEraseBackground already cleared the background
// but you are free to draw something else here etc...
}
/* Don't forget that what goes up, must come down. Make sure to
provide some mechanism, such as another button and another handler
to set the m_bDrawGraph=TRUE when you want to see the graph again.
Don't forget to Invalidate() to force a redraw.
IMPORTANT: Remember that OnDraw gets called frequently, even when
you did not explicitly call Invalidate(). OnDraw needs to know what
to draw in your client area at any moment when someone drags
another window over your window which effectively wipes out part
of the graph so Windows politely Invalidates for you to "redraw"
the graph.
*/
Anyway, I apologize for the clarification but I hope it helps a little.
|
|
|
|
|
Normally stack overflow is not a problem unless you have a lot of recursive functions within threads.
I'm looking for any kind of suggestion,articles, methodes,api to detect and prevent stack overflow on releases.
None MFC if possible but even MFC is fine.
Thanks
G_S
|
|
|
|
|
G_S wrote: I'm looking for any kind of suggestion,articles, methodes,api to detect and prevent stack overflow on releases.
Global variables.
Stack-based arrays.
Passing structures to functions by value.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm putting together a framework for Win32 consoles (to make it easier to change font, background color, change title, and to teach myself Win32) and I was curious if it would be possible to define my own escape sequences using C++ (like \n, \t, etc), to change the font, clear the screen, or do custom formatting. I already know how to change the font under Win32 but it would be convieniant if I didn't have to clutter up the code with function calls. Any ideas?
|
|
|
|
|
CoffeeAddict19 wrote: I already know how to change the font under Win32 but it would be convieniant if I didn't have to clutter up the code with function calls. Any ideas?
How would you prefer to do it?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
There would be maybe 3 classes defined and 4 involved. 2 classes (one for each buffer, and duplicates of each other) do the actual low level Win32 function calls for their respective buffers. They would use this function to change the font, change the buffer size, the cursor position, and the window size:
void SetBufferInfo(int NewXCord, int NewYCord, PrintColorType ForeColor, PrintColorType BackColor, SetBufferType BufferAction); //sets buffer info
Another class which contains both of those buffer classes as private members acts as an interface between the client and the other two low-level buffer classes. It uses a set of of functions to change the title, change the font color, clear the screen, switch the active buffer so I can do double buffering, etc.
Another class (the client in this case) would set it up so that certain escape sequences, when read from a stream, would invoke the functions in the interface class described above.
-- modified at 14:18 Friday 9th June, 2006
|
|
|
|
|
CoffeeAddict19 wrote: Another class (the client in this case) would set it up so that certain escape sequences, when read from a stream, would invoke the functions in the interface class described above.
If you define a reader to look at each charater (or set of characters) before displaying them, you can do anything you want. What you are basically doing is writing your own markup language in that case.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
CoffeeAddict19 wrote: Another class (the client in this case) would set it up so that certain escape sequences, when read from a stream, would invoke the functions in the interface class described above.
So what's the problem? When those special characters are encountered, call the appropriate functions.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Would using an if statement to check each character encountered (to see if it's a tag) slow the program down signifigantly?
|
|
|
|