|
So to recap:
you have an array of layers. Each layer has an array of pointers to a base class. Your WM_PAINT steps through these arrays in order and draws everything again to a CBitmap, then to the screen.
rainfallc wrote:
i used another CArray to keep track of which layer is hiding.
Why not make a layer class that has a hidden property and holds all the things you are drawing, if you're doing it that way ? You're risking fragmentation between different aspects of what should be the same data.
rainfallc wrote:
please give me more hints
OK.
1/ If you don't need W95 support, use GDI+. It's the easiest way to do layering
2/ Don't use CBitmap, because when you come to save & load images, you'll only be able to deal with images the same bit depth as your screen. Use GDI+::Bitmap, which has the advantange of letting you load and save a ton of formats as well.
3/ Don't draw everything to the screen every time, unless you want to be able to reselect items you have previously drawn to edit/move/delete them. If you're trying to write a drawing package, you're stuck with this, but I'd still impliment suggestion 4, and redraw a layer using your array only when you want to select/delete something
4/ Make a vector of layer objects, a class that encapsulates the bitmap that represents the layer ( which has it's alpha channel set so that it can be drawn on top of lower layers correctly ), the objects in the layer if you want to select them, if the layer is to be drawn or not, etc.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
thanks for reply
i create a tool class called Eraser,
now i show three layers on the screen, the topmost one i am editing,
i draw a line on it, i want to ERASE someparts of the line, but those parts
are inside the lower layers`s shapes` region.
How could i set the Eraser`s mode , which just delete the current layers` content,.after i release the mouse button, lower layers show as before, but current layer`s image has changed?
u said:
Make a vector of layer objects, a class that encapsulates the bitmap that represents the layer ( which has it's alpha channel set so that it can be drawn on top of lower layers correctly )
could u offer a short program for the suggestion above? do u mean to draw a bitmap with its alpha channel set on other layers` images?
thanks again
|
|
|
|
|
rainfallc wrote:
How could i set the Eraser`s mode , which just delete the current layers` content,.after i release the mouse button, lower layers show as before, but current layer`s image has changed?
By erasing by reseting the alpha channel in just the layer you are drawing on. Making an eraser would seem to suggest you'd be better not keeping track of individual shapes, but just bitmaps. It's not going to take long for your paint method to groan under the strain of rerendering all this stuff.
rainfallc wrote:
u said:
Make a vector of layer objects, a class that encapsulates the bitmap that represents the layer ( which has it's alpha channel set so that it can be drawn on top of lower layers correctly )
could u offer a short program for the suggestion above? do u mean to draw a bitmap with its alpha channel set on other layers` images?
thanks again
A short program ? No. Which part do you need help with ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
oh i see, thanks very much,
if i have any more questions , please offer the help again
|
|
|
|
|
Always glad to help - just try to impliment what I've suggested and ask when you get stuck. I've also written a GDI+ paint program called Doodle on CP, which may help you get started in GDI+.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
I'm calling the Win32 api function SHBrowseForFolder to display a Browse folder dialog. It allows a callback fn to be specified. Can anybody tell me, using the hwmd supplied in the callback is it possible to access the dialog's device context. Can this be done with Subclassing.
Thanks for reading
John
|
|
|
|
|
I have never used this function before, but does the HWND represent the dialog or the owner of the dialog. Anyway, you can always call GetDC to get the DC of a window. The thing that you will need to worry about is if that handle is the dialog or not. If that handle is the parent of the dialog, you can always enumerate through the windows to get your dialog handle, or cache a handle somewhere.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
I´m developing a program and I need a class for CtreeCtrl, with multiple selection of items and Drag and Drop of them between two CTreeCtrls(or Ctreeview).
Thanks in advance.
Using Visual C++ 6.0.
Windows 2000.
|
|
|
|
|
Is it possible to add a toolbar to a modal dialog?
I tried, but ended up with assertion errors, was just wondering if it can be done!
Thanx
funbag!
skydiving....if at first you don't succeed, you're fecked!
|
|
|
|
|
In theory, no, but I believe in practise it is possible to hack a solution, so long as you don't want them to float.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Hi,
We have a big monolitic ( ), project, that takes half an hour to compile ( Scassi HD, and 500 Mb. Memory), we don´t have time to chop it into smaller pieces ( now it´s not the time for that )...
... But we have like three more computers free, so would it be possible to send to that computers a bunch of files, and that machines could compile them ? ( so if I have 400 files I could compile 50 here, 50 there, 50..., in paralel).
Does can be done on VStudio 6.0 ? And .net ? ... or that´s to good to be true ?
Thanks in advance, Greetings
Braulio
|
|
|
|
|
Hi
i got a serious Problem with the Blocking Sockets Part of WinSock2.
A Java Applet is connecting to my TCP/IP Server (written in C++) - and now they are talking... and it works - ... but everytime the Java Applet sends a Message to the C++ the LAST BYTE doesn´t arrive. Its there when the next message is sent from the Applet - but until then.... no LAST BYTE....
does anybody know how to workaround - or WHY the H**** this is occuring ?
Daniel
|
|
|
|
|
Do you have more information? What protocol do you use on your socket? HTTP, FTP, in-house?
If the protocol you use specifies in its header the number of incoming bytes, make sure you don't miscalculate.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
I want to record sound with callback function.
I call waveInOpen, waveInPrepareHeader, waveInAddBuffer etc. successfully.
And I can get WIM_OPEN and WIM_CLOSE message in the callback function.
BUT I CAN'T get WIM_DATA message! Why???
BTW: I can get MM_WIM_DATA message when I use threads instead of callback
function, and I can get WOM_DONE message when using callback function waveOutProc.
|
|
|
|
|
Hey!
I found the answer.
I forget to call waveInStart.
|
|
|
|
|
As title.
I'm amumu, and you?
|
|
|
|
|
iS it possible to get the system's image list and use that to a tree control so that it the images in the tree control of Windows Explorer is the same as with the images of the tree control my application??
|
|
|
|
|
How do i capture the whole viewport size of a CScrollView to a bitmap?...
I'm making a paint program and i want to save the whole drawing including the hidden part of the bitmap.... (the part which is not scrolled)...
I tried Bitbliting the ScreenDC into memDC which has a bitmap attached to it
but it only captured the visible part.. worst it also captured the Scrollbars...
|
|
|
|
|
Hi,
I am using AfxMessageBox() API in my application.Sometimes the message box doesn't come up and when I debugged and saw found that the return value is 0 which means that there is no enough memory to display the message box.What do I do to solve this problem?
Thank You.
Yamuna.E.
Yamuna.E.
|
|
|
|
|
Buy more RAM ?
I've NEVER had AfxMessageBox fail, what makes you think it's memory related ? When does it happen ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Even for me this is the first time AfxMessageBox fails.
MSDN tells that AfxMessageBox on failure returns 0 and that it is due to no enough memory.
I forgot to mention the scenario.
This messagebox I call from within a thread function(via CreateThread) which takes as its parameter the string to be displayed and I am sure there is no problem with string passing.This I made sure by hard-coding the string just to check whether it works fine with hard-coded string value.But even in that case I got the same problem.
But now I tried using MessageBox API instead of AfxMessageBox.Its working fine.But couldn't get the reason behind the problem.
Thank You.
Yamuna.E.
Yamuna.E.
|
|
|
|
|
It's certainly an odd problem. In the future, TRACE or OutputDebugString will allow you to check a variable value in Debug mode without having to bring up a dialog.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Fine Thank You.
Yamuna.E.
Yamuna.E.
|
|
|
|
|
Hi all!
I want to do next: user clicks the button, and Web Browser replaces by richedit control (in a dialog). TROUBLE: after hiding of web browser, its window handle become not valid. Here's a code:
void CCalendarDlg::OnViewEditSwitch()
{
CString strBtnText;
m_btnEditView.GetWindowText(strBtnText);
if(strBtnText == EDIT_BUTTON_TEXT)
{
m_btnEditView.SetWindowText(VIEW_BUTTON_TEXT);
m_Browser.ShowWindow(SW_HIDE);
m_wndRichEdit.ShowWindow(SW_SHOW);
}
else
{
m_btnEditView.SetWindowText(EDIT_BUTTON_TEXT);
m_wndRichEdit.ShowWindow(SW_HIDE);
m_Browser.ShowWindow(SW_SHOW);
}
}
ERROR:
Debug assertion failed here:
BOOL CWnd::ShowWindow(int nCmdShow)
{
ASSERT(::IsWindow(m_hWnd));
if (m_pCtrlSite == NULL)
return ::ShowWindow(m_hWnd, nCmdShow);
else
return m_pCtrlSite->ShowWindow(nCmdShow);
}
Help, please!
|
|
|
|
|
I solve the problem so:
void CCalendarDlg::OnViewEditSwitch()
{
CString strBtnText;
m_btnEditView.GetWindowText(strBtnText);
if(strBtnText == EDIT_BUTTON_TEXT)
{
m_btnEditView.SetWindowText(VIEW_BUTTON_TEXT);
//m_Browser.ShowWindow(SW_HIDE);
m_Browser.SetWindowPos(this, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOZORDER);
m_wndRichEdit.ShowWindow(SW_SHOW);
}
else
{
CRect rc;
m_wndRichEdit.GetWindowRect(&rc);
::MapWindowPoints(HWND_DESKTOP, *this, (LPPOINT) &rc, 2);
m_btnEditView.SetWindowText(EDIT_BUTTON_TEXT);
m_wndRichEdit.ShowWindow(SW_HIDE);
m_Browser.SetWindowPos(this, 0, 0, rc.Width() , rc.Height(),
SWP_NOMOVE | SWP_NOZORDER);
//m_Browser.ShowWindow(SW_SHOW);
}
}
But I'm interested in problem description... Why handle became invalid?
|
|
|
|