|
i've just overriden the WndProc... no code added to the base override...
this is what i have...
a) a vc++ 6.0 Mdi app (.exe)
b) a vc# dll with:
- class A (interface) (cominterop)
(i have to call some methods and access some properties)
- class B (windows form)
in the vc++ 6.0 mdi app i create an instance of classA
then i call a method from class A wich does this:
public void SomeThing()
{
Form1 f = new Form1();
f.Show();
}
and this is what i intended to do:
public void SomeThing( Form parent)
{
Form1 f = new Form1( Form parent);
f.MdiParent = parent;
f.Show();
}
i just want to say to the VC# winForm that his container is the VC++ 6.0 APP
what can i do?
|
|
|
|
|
The simplest thing that comes to my mind is to reparent the C# form window.
This can be done with simple things :
- the window handle of the C# form is obtained using this.Handle if you use managed code. Otherwise, from C++ code you can enum windows or use FindWindow(...) with a particular caption to get that window handle.
- then, use WIN32 ::SetParent(hwndForm, hwndNewParent /*MDIapp frame window hande*/) to reparent the form.
Good luck!
|
|
|
|
|
Hi,
I have a image control(child of main window) in a window,which is created with WS_CLIPSIBLING flag.
But when i move some other window over my main window. image control receives WM_PAINT message. How can i avoid receiving the WM_PAINT message for the image control?
|
|
|
|
|
I dont know any way to avoid recieving WM_PAINT but
you can ignore (comment code out) where you handle
the message.
jhaga
|
|
|
|
|
Why this generates "test.pmjaaaaYYYYY" as output??
<br />
<br />
<br />
<br />
<br />
char* szBuffer = NULL;<br />
int i = 0;<br />
<br />
CFile f;<br />
<br />
if( f.Open ("F:\\test\\id.txt", CFile::modeRead ) ){ <br />
try {
i = f.GetLength();
szBuffer = new char[i];
<br />
if(szBuffer != NULL)<br />
<br />
f.Read(szBuffer, i); <br />
f.Close();
<br />
} <br />
<br />
catch (CFileException *e) <br />
{ <br />
AfxMessageBox ("Error!"); <br />
e->Delete(); <br />
}
<br />
}
<br />
CString csPath = szBuffer;<br />
<br />
SaveStream(csPath);<br />
<br />
if(szBuffer != NULL) <br />
delete [] szBuffer;<br />
Thanks, Mark
|
|
|
|
|
The file you are reading won't have a 0 terminator. Try:
szBuffer = new char[i+1];
szBuffer[i] = 0;
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Now it works. Will a "Detected memory leaks!" be a problem?
Thanks, Mark
|
|
|
|
|
macmac38 wrote:
Will a "Detected memory leaks!" be a problem?
Short answer, Yes.
Also if you are reading a fixed length file, you should write using fixed length routines, not a stream. ie, don't mix file i/o types unless you have to.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hi,
As, franks mentioned, it happens because, the output is not null-terminated. Here's the code snippet, which very well read your file, without any memory leaks.
-----------------------------------------------------------
CFile oFile;
DWORD dwFileLength;
if(oFile.Open("F:\\test\\id.txt", CFile::modeRead))
{
try
{
CString strBuffer;
dwFileLength = oFile.GetLength();
LPTSTR szBuffer = strBuffer.GetBufferSetLength(dwFileLength);
oFile.Read((LPVOID)szBuffer, dwFileLength);
oFile.Close();
CString csPath(strBuffer);
strBuffer.ReleaseBuffer();
}
catch(CFileException *e)
{
AfxMessageBox ("Error!");
e->Delete();
}
}
-----------------------------------------------------------
regards
~Hari~
|
|
|
|
|
Sorry if this is a silly question, but I'm a little confused.
I've got a class MyClass and I want to have a CArray of MyClass objects in the Doc class of my application.
Ex:
In CMyAppDoc
CArray <<cmyclass,cmyclass>> m_myArray;
My question is.
How I have to declare and have acces to the array to touch the values of it directly (by reference) in the view?
CMyAppView
?????
Best Regards
Dr. Pi
|
|
|
|
|
Hi,
i had the same problem and it seems to be impossible.
i created a lot of instances of my class with 'new' and than i stored the pointers in an CObList or CObArray.
This array stores only the pointers, so clean the memory up ('delete pClass') when deleting the array.
Dr-Kuulun
|
|
|
|
|
Try this:
CArray<CMyClass*,CMyClass*&> m_MyArray;
And to acces any data:
CMyClass* Temp = m_MyArray[i];<br />
Temp->DoSomething();
Hope this helps !
Ced
|
|
|
|
|
You are probably better off using the standardized std::vector class:
std::vector< CMyClass > m_myArray;
... now you can fill the vector e.g. using push_back()...
And now you can use
CMyClass c = GetDocument()->m_myArray[0];
to access the first data item in the associated document.
Hope this helps
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I have something similar in one of my projects.
class CMyDoc : public CDocument
{
public:
void GetAddressList( CDWordArray *pAddresses );
private:
CDWordArray m_arrAddresses;
};
void CMyDoc::GetAddressList( CDWordArray *pAddresses )
{
pAddresses->RemoveAll();
pAddresses->Append(m_arrAddresses);
}
void CMyView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CMyDoc *pDoc;
CDWordArray arrAddresses;
pDoc = GetDocument();
pDoc->GetAddressList(&arrAddresses);
}
Hope this helps, or at least gives you an idea.
|
|
|
|
|
Hi,
I have a bitmap displayed in a window. When some other window is moved over this window. This bitmap gets refreshed,i don't want that to happen. I don't want to create bitmap with WS_CLIPSIBLINGS style. Any idea how can i avoid the bitmap to get refreshed?
Regards
|
|
|
|
|
Why? why did you say (write) that you don't want it to get refreshed? (just curious!)
ÿFor the bread of God is he who comes down from heaven and gives life to the world. - John 6:33
|
|
|
|
|
Could anyone who are good in image processing give me some advises for my question:
1. How to do an 'edge detection' on a bitmap?
2. How to change the contrast of a bitmap?
thanks you.
|
|
|
|
|
1. apply a convolution filter (see "Laplacian")
2. to raise contrast, lower the low pixel values, raise the high pixel values. to lower contrast, do the opposite.
-c
|
|
|
|
|
dear all,
how can i get the handles of controls present in my dialog.
thanx
|
|
|
|
|
hello,
I don't know exactly what you want but:
1. if you are programming MFC and you need a CWnd pointer to an edit box(his resource id is for example IDC_EDIT1) or any other control in your dialog (dialog1) :
dialog1.GetDlgItem(IDC_EDIT1);
2. in old windows programming style
GetDlgItem(dialog1, IDC_EDIT1);
where dialog1 is a handle to your dialog and IDC_EDIT1 is the resource id of the control
for both functions the return value is what you want....
|
|
|
|
|
thanx a lot _crs_
thats exactly what i was asking for,
but how do i get the handle of dialog box (dialog1 in ur example)
|
|
|
|
|
Use CWnd::GetSafeHwnd() for any window.
|
|
|
|
|
... if you are in DialogProc - it looks like this
LRESULT CALLBACK DialogPROC(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
handle to the dialog is "hDlg" your first parameter
when you create a dialog ...
DialogBox(hInst, (LPCTSTR)IDD_DIALOG1, hWnd, (DLGPROC)DialogPROC);
where "hInst" is the application instance,
"hWnd" is a handle to parent dialog window in your case will be main window
"IDD_DIALOG1" is the dialog resource id and
"DialogPROC" is the dialog callback procedure (like WndProc for your main window)
if you use MFC look at the other answer ....
|
|
|
|
|
How to edit vertical center?
I have searched over the ISDN, but no answer.
Please help me!!
|
|
|
|
|