|
Pas de quoi! If u need anything just post it!
Papa
Murex Co.
|
|
|
|
|
Hi, im used to doing gfx programming with DX or OGL but now I have to do some stuff in GDI. Im currently having a tearing problem in GDI. Normally in DirectDraw I would use the function to wait for the vertical refresh ( vsync ) but in GDI I don't know what to do... Is there a similar function in the Win32 SDK ?
Thank you for any help you can provide.
|
|
|
|
|
I dont think MS has a provision for vsync in windows gdi... which really sucks.
// Rock
|
|
|
|
|
GDI was never at all intended to do that type of stuff.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Wow this is bad, I am only putting a huge rect on the screen then a smaller one on top of the first and I get tearing... boy GDI aint so great then.
|
|
|
|
|
Hi,
in a dialog which requests repeated WM_PAINT (by not validating client area) you get nasty little side effects. The repeated WM_PAINT prevents another window (the parent which does the message pump) to get redrawn sometimes. For example after maximize/restoring dialog the parent window is not repainted.
You can get an code example on NeHe's OpenGL page. It uses the mentioned repeated WM_PAINT method, which has some advantages if running a standalone window.
Okie... back to my problem. I tried several things to force an update of my parent window:
Attempt number 1
UpdateWindow(hWndParent);
No success, nothing happens.
Attempt number 2
RedrawWindow(hWnd, 0, 0, RDW_NOINTERNALPAINT);<br />
RedrawWindow(hWndParent, 0, 0, RDW_INTERNALPAINT | RDW_UPDATENOW | RDW_INVALIDATE);
Failure. Spy++ shows that as long as WM_PAINTs get created for my dialog, the parent window can not get a WM_PAINT. Yes, every other message is send, but no WM_PAINT is created. *sigh*
Attempt number 3
In my WM_PAINT handler I validate the client area and send a custom message:
PostMessage(hWnd, WM_CONTINUEPAINTSOON, 10, 0);
which will then again trigger WM_PAINT with
InvalidateRect(hWnd, NULL, FALSE);
Hopeless idea. Also tried to delay a new WM_PAINT by decreasing the wParam value until it's 0 and meanwhile create another WM_CONTINUEPAINTSOON (did you see the 10 above?). No change to the good, just causing more brawl on the message queue.
Attempt number 4
This time my WM_PAINT handler validates the client area and calls:
SetTimer(hWnd,1,0,NULL);
Then my WM_TIMER handler will invalidate the client area and so again trigger WM_PAINT.
Well, this time it works somehow, more bad. Of course my dialog update is poor (I mean the frame rate sux!). Which is no wonder, because SetTimer() has a low granularity ...I think arround 55 ms (I got ca 20 FPS).
Any ideas for a solution? Basically I eighter need to force the window parent to update (which I failed with attempt 1-3)
-or-
I need to stop the repeated WM_PAINT to give another window a chance for WM_PAINT and then retrigger my WM_PAINTs.
Thx for help, sorry for long posting! Feel free to ask question or ask for executable for testing.
Moak
|
|
|
|
|
Wasn't that a beginner question?
okie, I try with a worker thread.....
|
|
|
|
|
yep, worker thread works fine (and is just a few lines extra code)
|
|
|
|
|
I have a pointer defined in my header:
unsigned char *m_pData;
In my class constructor I initialize the pointer:
pData = NULL;
In my class source code I allocate memory:
m_pData = new unsigned char[m_fileLen];
In my destructor I delete the memory:
if(m_pData != NULL)
delete [] m_pData;
I keep getting memory leaks when the app is closed...I have set breakpoints and the delete in the destructor is being called. Why am I getting these leaks?
|
|
|
|
|
I hade a typo in the post, should read
m_pData = NULL;
Why am I leaking...need a can of stop leak
|
|
|
|
|
i'll ask an obvious question: how many times are you doing the allocation?
-c
Cheap oil. It's worth it!
|
|
|
|
|
Another obvious question: is the class that contains this code being dynamically allocated, and if so, is that class instance being deleted?
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
[Get Check Favorites 1.4 Now!]
|
|
|
|
|
Obviously ure allocating it more than once, make sure ure not losing any pointer over there, as a general rule the delete operator should be called as much as the new operator!
(Could be exceptions)
Papa
Murex Co.
|
|
|
|
|
|
Thanks to all that replied...It was the first suggested problem...the app was allocating the memory twice in different places in the code. Sometimes the brain goes numb before the body does...too much overtime...all it took was someone to ask the obvious question, the one my brain wasn't asking.
|
|
|
|
|
can someone please explain what i can do with make files (.mak, .make) in practice? i see options in compilers to make those files everywhere yet i don't see any options to do anything else with them...
It's a mystery to me, please explain or show me where it is explained, i'd be very thankful.
Kuniva
--------------------------------------------
|
|
|
|
|
Look up nmake on MSDN. nmake will allow you to compile .mak files.
Michael
Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor
|
|
|
|
|
I'm working on building an integrated tool for MS Dev Studio. I read this article:
http://www.codeproject.com/macro/DevStudioHost.asp
It has an example of how to create an add-in which hosts a GUI within dev studio. In order to create the window within dev studio, I need handles of dev studio:
HINSTANCE hInst = AfxGetApp()->m_hInstance;
DWORD threadID = AfxGetApp()->m_nThreadID;
When the add-in executes, I get an access violation from the above statements. I even tried compiling the source from the article on codeproject and got the same error!?!
Any help would be appreciated.
|
|
|
|
|
you're getting the access violation because AfxGetApp is returning NULL. why it's returning NULL, i can't say without seeing more of your code. where are you calling it from?
-c
Cheap oil. It's worth it!
|
|
|
|
|
I'm building this as an add-in for visual studio. I'm calling it from CDSAddIn::OnConnection. Here is a description of the thinking behind how it all works and some more code.
So, once in the CDSAddIn::OnConnection() method we store off the current CWinApp's hinstance and threadID. Then the AFX_MANAGE_STATE macro is used to switch the state so that our add-ins access to it's resource's will function correctly. Note that the manage state macro is done after the storing of the hinstance and threadID - if we had switched state before, then the values would be different - what we want is to have the hinstance and threadID for the Developer Studio app.
// This is called when the user first loads the add-in, and on start-up
// of each subsequent Developer Studio session
STDMETHODIMP CDSAddIn::OnConnection(IApplication* pApp, VARIANT_BOOL bFirstTime,
long dwCookie, VARIANT_BOOL* OnConnection)
{
HINSTANCE hInst = AfxGetApp()->m_hInstance;
DWORD threadID = AfxGetApp()->m_nThreadID;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
|
|
|
|
If you have a CListCtrl, and you set the option to have a border (either through the GUI interface or WM_BORDER option), how do you find the border width ?
|
|
|
|
|
I haven't tried, but I think you can calculate the it by copmuting the difference in width between GetWindowRect and GetClientRect (and dividing by two.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Look at ::GetSystemMetrics() in MSDN...
int xBorder = GetSystemMetrics(SM_CXBORDER);
int yBorder = GetSystemMetrics(SM_CYBORDER);
|
|
|
|
|
Does anyone know the commands to overide your applications taskbar options?? i.e. - change the right click and left click functionality of the box that sits in the taskbar?? How would i replace the right click menu (you know restore/minimize/maximize/close/etc) to a custom menu??
kevin
|
|
|
|
|
GetSystemMenu gives you a handle to this menu that you can later use to modify it to your taste.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|