|
Maybe you should Get the bits of the MemDc
Try this @ home. (B&B)
|
|
|
|
|
I hope there is nothing attched before you make those calls to Detach() or your program will have resource leaks.
After drawing to the bitmap via Rectangle, select pOldBitmap into MemDC. If either function SetBitmap() or Save() needs to select it into a DC, then neither one can do it until MemDC releases ownership. A bitmap can only be selected into one DC at a time.
INTP
|
|
|
|
|
I currently use a CTreeCtrl with checkboxes for each item. How can I know when I check an item.
Is there an event sent to the control or something else ? The method CTreeCtrl::Getcheck() works, but I must to have informations just when I click, to update several datas ...
--
Gizmo
|
|
|
|
|
Gizmo79 wrote:
How can I know when I check an item.
Have you looked at either the TVN_SELCHANGED or TVN_SELCHANGING notification?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
void C3StateTree::OnLButtonDown(UINT nFlags, CPoint point)
{
UINT uFlags = 0;
HTREEITEM hItem = HitTest(point, &uFlags);
if( uFlags & TVHT_ONITEMSTATEICON )
{
if(GetCheck(hItem))
{
TraverseDownAndSelectTree(hItem, false);
TraverseUpAndSelectTree(hItem, false);
}
else
{
TraverseDownAndSelectTree(hItem, true);
TraverseUpAndSelectTree(hItem, true);
}
}
}
Arjan
|
|
|
|
|
Thanks, it works fine.
I don't use the WM_LBUTTONDOWN event, but the NM_CLICK event and it works too.
I didn't know how to verify if the mouse was over the checkbox, but know, it's done. Tanks you.
--
Gizmo
|
|
|
|
|
Hello,
my MFC dialog based app uses a freeware activex I found on the net.
To use it, the relative ocx file must be registered in the system.
Is there a way to make the app do itself without the user having
to run regsvr32 c:\..... ?
I added the lines
STARTUPINFO si;<br />
PROCESS_INFORMATION pi;<br />
ZeroMemory( &si, sizeof(si) );<br />
ZeroMemory( &pi, sizeof(pi) );<br />
CreateProcess(NULL,
"regsvr32 MyOcx.ocx",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi );
inside InitInstance().
It seems to partially work:
with the ocx unregistered, the first time I execute the app
it brings out the information message box saying "DllRegisterServer MyOcx..."
From now on each time I execute the app first I see the box and finall the app.
I'd love to skip the first dummy execution and to close automatically the system info box without having to hit OK.
Any suggestion about this?
Thanks for the precious help.
Marco.
|
|
|
|
|
use "regsvr32 myocx.ocx /s"
NOTE: /s parameter this makes it register silently!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Hello,
I have a dialog, for example dialog3, which can be created by dialog1 and dialog2 through .DoModal(). How to decide which dialog is the parent dialog In the class dialog3?
thanks inadvance
|
|
|
|
|
dadacncn wrote:
How to decide which dialog is the parent dialog In the class dialog3
Are you talking about GetParent() , or IsKindOf() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
yes. I think I need GetParent() or IsChild(). But I don't know how to use them. do you have an example? maybe it will help me.
|
|
|
|
|
Haven't tested it, but this might work:
CWnd* pParent = NULL
pParent = GetParent();
if(pParent)
{
if(pParent->IsKindOf(RUNTIME_CLASS(CDialog1)))
elseif(pParent->IsKindOf(RUNTIME_CLASS(CDialog2)))
else
}
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thank you very much. but in the .h and .cpp files of CDialog1 need DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC.
|
|
|
|
|
I want to Serialize several HTMLs(2 or >2)with source into a single file.for example *.abc. when I load the file that saved,I can show the HTMLs in a htmlview.How to do this? I have never worked on file Serialize.I need your help.I use VC6.Thank you very much!
Alick
|
|
|
|
|
How about you create a CStringArray.
Copy each stream of HTML text into a separate CString.
Assign these CStrings to the CStringArray.
Serialize the CStringArray to your file.
When you reload it, each HTML 'file' will be in its own CString.
You can use each CString as the HTML text for your view.
|
|
|
|
|
Thank you for your idea. but how about the source(jpg,gif etc.) and how to encapsulate? I intended to use ziplib. what I want to do is just the direct explore modal of winzip(double click on a zip file,winzip will open it,doesn't extract exactly you can see the files encapsulated in the zip file).
In my condition there is just one addition that I encapsulated just HTMLs with source.I hope I can open a html file in my HtmlView not lanuch IE. That's all.
Thak you all the same,Blake.
|
|
|
|
|
How do you set the position of a dialog box, as you cant call SetWindowPos before DoModal, nor can you call it after, as the dialog box window doesnt exist.
Thanks
|
|
|
|
|
Do it in OnInitDialog()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
How to access a CD Writer programatically for reading and writing files from hard disk into CD place in the CD Writer in VC++
Madhavi
|
|
|
|
|
There are several ways depending on what exactly you want. If you are willing to go XP only, you can use a built in API for burning data disks. Doesn't work with 2000 or 98 though.
NERO has (sells? I'm not sure) a kit with an API for doing this. Even though I've never checked it out I'd guess this is the best solution. It works around firmware bugs in different drives, and the differences between the various MMC versions. I haven't looked at it so I don't know how much it does. There are a couple others that google will find too.
The hardest, but the one that gives you the most control: get the scsi specifications form t10.org. (nearly all CD drives speak scsi, even IDE drives. I don't think there are any exceptions faster than 2x or maybe 4x) Get the ISO specifications (free from ECMA, otherwise pay), or UDF specifications (half from OSTA, half from ECMA) and start working. Then figure out how to talk to the device directly with your OS (isn't hard, but NT bases systems are different from 95 based systems, and unix is different again). Last get one of every device and work around all the various bugs that each one has.
I've done the last one myself. It gives you the most control, but you also have to control a lot. Power calibration, write speed, track mode. Some of the above you have several choices, and you almost have to guess which one you should use.
|
|
|
|
|
Hi!
I have had a problem yesterday and written code as suggested. I have it now working.
I have a class CBook and another class CSubject . CSubject has a member which is a CList of CBook pointers. I want to serialize my CSubject object together with any CBook objects it contains.
I wrote my code like was suggested and inherited both from CObject . I overloaded the CObject Serialize() member function in both CBook and CSubject and added the MFC serialization macros. When serialize a CSubject object to disk the data file that is created contains all the data I want. The data is the subject and all the books I add to the subject. So that works very well but now I come to deserialize from disk and I have problems. How do I know how to create enough books when I am calling the Serialize() function? I thought I must be able to in the CSubject::Serialize() function count the books in the list first and store the number. When I deserialize I then know how many to try to get?
Is this the right way to do what I want?
What is really the point in the COBject inheritance? What value must it give to me as I think I am doing all the work in my Serialize() functions myself!
|
|
|
|
|
I suggest you to change the architecture of your class to :
This is corrected way to serialize a List Object.
I Write only the important parts to serialize a list.
//Header File .h
class CBook: public CObject
{
public:
DECLARE_SERIAL(CBook)
CBook();
// You must implement CopyConstructor and = operator.
CBook(const CBook& objSource);
CBook& operator=(const CBook& objSource);
virtual void Serialize(CArchive& ar); // Implement your serialization
public:
CString m_sName;
};
class CBookList: public CList<cbook, cbook&="">
{
public:
CBookList();
virtual ~CBookList();
}
template <> void AFXAPI SerializeElements <cprvfile>
(CArchive& ar, CPrvFile* pNewPrvFile, int nCount);
class CSubject : public CObject
{
public:
DECLARE_SERIAL(CSubject)
CSubject();
virtual void Serialize(CArchive& ar); // Implement your serialization
public:
CString m_sName;
CBookList m_BookList;
};
// Implementation File .cpp
// The Secret of Serialize List Elements !!!!
template <> void AFXAPI SerializeElements <cbook>
(CArchive& ar, CBook* pNewBook, int nCount)
{
for (int i = 0; i < nCount; i++, pNewBook++)
{
// Serialize each CBook object
pNewBook->Serialize(ar);
}
}
Enjoy it
Rodrigo Pinho Pereira de Souza
|
|
|
|
|
Thank you.
This looks hard. Is there any benefit over what I was suggesting I do with storing the number of objects so I know how many to restore?
Also what about using CObList ? This provides a Serialize() function which I may be able to call. Will this restore my list of objects with no further work? I think I could have a data member in my CSubject class which is of type CObList . When CSubject::Serialize() is called I must then only have to call CObList::Serialize() yes?
I am quite confused with all this. I can make it work now though and it looks good but then I hear that there are other ways that can be better though not easier
I also still do not understand why CObject provides any function to me. As I can tell it just gives me a Serialize() function as a declaration which I must then write anyway.
|
|
|
|
|
The benefit is that with this implementation, you will using a real Object Oriented Concepts.
I think that is more clear to understand, and easy to implement than use CObList Member Variable.
Look in MSDN for template SerializeElements, and you will see that Microsoft recommend use this template when you want to serialize element. Is more efficient and trustable.
If you want, I can send you an example for Serialization of List. I will write an article, that I will use this example.
mail me : rpinho@mobiledeveloperspace.de
regards,
Rodrigo Pinho Pereira de Souza
|
|
|
|
|
You could Serialize out the number of books written before the serialized books. Then on deserialize read the number of books, create the books and read them back in.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|