Link to home
Start Free TrialLog in
Avatar of Excalibur81
Excalibur81

asked on

Drawing wavepattern to window

Hi all,
Im using the LineTo() method to draw the wave pattern of a wave file to my window, and ive come across a few problems....

First of all, i want it in a scrollable groupbox, or something similar...

Second, i need the lines to stay if i minimize the app (right now, they dissapear when it minimizes!!)

Regards,

Robert
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Excalibur81
Excalibur81

ASKER

ok that helps heaps!!

so i would make an array of points, and use the PolylineTo() method to draw the array?
i guess this would be the sensible way to do it...

regarding the clipping region stuff...
im creating my groupbox, and giving its handle the name hGroupbox..
i then call HDC dc = GetDC(hGroupbox);
but the wave draws past the groupbox onto the main window..
i guess this has somthing to do with clipping regions right>? so how do i tell the app to only draw in the groupbox?

regarding the last comment,
would i use ScrollWindowEx to say scroll a groupbox, and perhaps have a trackbar below the groupbox to adjust the postion of 'scroll'? So effectivly, im not actually drawing the entire wave, but just the part that the trackbar says to view...

hope you can understand this gibberish!!

Cheers,
Robert

oh, and btw, im not sure if im using mfc or not...

sorry, i only started c++ programming 2 weeks ago...

im using a 3rd party compiler called devc++ , and it doesnt have any gui to add buttons etc to the prog, i have to do it all in code...

this probably means nothing...... :P

A GroupBox control is actually just a type of STATIC control.  Like most controls, its window class includes the style bit CS_PARENTDC.  What that means is that when you request its DC, you actually get the DC of the Window in which it resides.  That's why ypu can draw outside of it.  You need to limit where you draw, or create a clipping region and use SelectClipRgn (or use GetDcEx and pass in a clipping region) if you want the GDI system to automatically clip your output.

There is a lot to learn and, alas!, I can't teach it all to you.  You need to get your hands on a good book.  The best is Charles Petzold's "Programming Windows"

-- Dan
Hey thanks youve been heaps of help!!

Just one more q...

im using the following :
     HRGN region = CreateRectRgn(20, 250, 600, 250);
     dc = GetDCEx(hwnd, region, DCX_LOCKWINDOWUPDATE | DCX_CLIPCHILDREN);


but when i test for dc == NULL, it always comes up true, and so my drawing isnt working anymore...

hwnd is the handle of my parent window...

if i pass '0' as the first param , the drawing goes to the desktop, (proving the rest of my method works ok...) and if i pass hGroupbox (handle of my Group box), it comes up null as well....

so whats going on???
I don't kniow why you get an error.  Most common reason is that the hwnd parameter is wrong.  If you're sure that's ok, try it with different or no flag parameters.

As with all errors, you can call GetLastError to obtain additional info.  You can use the VC++ menu command Tools/Error Lookup and type in the error value to get some info.

-- Dan
hmm, well i already tried it with no flags, and im sure hwnd is right cause its passed straight from the wndProc!!

ok, ill have a fiddle anyways, but the points go to you!
i found out why, its cause i needed to set the style of my winclass to either CS_CLASSDC, CS_OWNDC or CS_PARENTDC

thanx for the help!