|
how to add ActiveX control in a MDI application using VC7
i want to add the windows media player Component in my project to open it in a window inside my application .
|
|
|
|
|
On your menu, go to 'Tools', then 'Add/Remove Toolbox items...' Select the tab labeled 'COM Components' and find the control you're looking for in the list. It'll be added to your toolbox. It'll probably add some classes to your project also.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hello,
I am working with the development of ActiveX controls in VC.NET
In my project I am using the following Classes.
1. App class (added by framework)
2. Ctrl Class (added by framework)
3. CMyclassFrameWnd class(added by me and derived from "CFrameWnd" class)
4. CMyclassView class(added by me and derived from "CView" class)
Now, I am creating a frame window in the control and connect a view created to this frame window.
coming to the matter, I want to add a mouse click event to the ActiveXcontrol.This event should fire upon clicking the View(View Class) area of the cotrol.
How can I do this?
With thanks in advance,
Jahfer,
eSoft.
|
|
|
|
|
In your ClassView pane, there should be an entry for whatever the name of your project is with 'Lib' on the end of it (something like MyControlLib). Under that node there should be a node that ends with 'Events' (something like _DMyControlEvents). Right-click on this node choose 'Add' from the popup menu, and select method. Specify the things you need for this event like any parameters. Then in your mouseclick handler, call this method before or after any default processing depending on what you want to allow the user to be able to do.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
I HAVE A FEW QUESTIONS......GLAD IF ANYONE U COULD GIVE ME A HAND....
1)what is the difference between WM_PAINT and WM_NCPAINT
2)IF MY DIALOG DRIVEN PROGRAM (Xyz)......HOW DO I CALL THE CXyzDlg::OnPaint()....FROM AN ANOTHER CLASS SAY CMYSTATIC???IS IT POSSIBLE TO CALL IT???
THANX....ALOT IN ADVANCE...
|
|
|
|
|
Easy on the caps lock .
WM_PAINT is sent to a window when the client area (i.e. the bit in the middle where your controls etc go) need to be repainted.
WM_NCPAINT is sent to a window when teh non-client (NC) area (e.g. the title-bar, and borders) need to be redrawn.
You can cause the OnPaint function to be called by invalidating part of the window (I believe, it may require slightly more than this, anyone?) - I believe the function you're looking for is CWnd::InvalidateRect().
HTH,
--
Andrew.
|
|
|
|
|
Andrew Peace wrote:
I believe, it may require slightly more than this, anyone?
Yes, you will need to call say UpdateWindow() .
I personnally like RedrawWindow() as you do not need to use Invalidate() or InvalidateRect() , the region is specified within the parameters to RedrawWindow()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
wait a sec.....
what is the difference between Invalidate() and UpdateWindow()......arent they both used for repainting??
can u enlighten me on thiz plz!!!!!
thanx....for the prev answer!!!!!
|
|
|
|
|
Invalidate marks a region that it needs to be repainted but does not cause a WM_PAINT message to be sent.
On the next WM_PAINT message the region is repainted.
UpdateWindow will send the WM_PAINT message.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
easy on the caps....lol....ok....
thanx for ur reply.....
can u tell me how can i call the Onpaint() function of the dlg class from an another class say CMyClass??
thanx for ur help.....
|
|
|
|
|
Either call UpdateWindow() or RedrawWindow() from the CDialog based class.
or
Use SendMessage() to send a WM_PAINT message to the dialog window.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
just one more question.....;)
can u tell me how can i call the Onpaint() function of the dlg class from an another class say CMyClass??
right now i use the timer function which is defined in the dialog to update the dialog box......can u suggest an another method whereby which i am able to call the OnPaint() function of the dialog class from the CMyClass???
NOTE:actually the CMyClass being a derived calss ......i have put in message handlers such as 'mousemove()'...etc....and when such mouse action takes place......it is supposed to update the dialog box......
thanx a lot for ur prevoius replies.....
|
|
|
|
|
The easiest way to do this is to pass a pointer to the dialog into the CMyClass. We will call the dialog CMyDialog.
CMyClass header file
public:
void SetDialog(CMyDialog* pDialog);
<p></p>
private:
CMyDialog* m_pDialog;
CMyClass cpp file
void CMyClass::SetDialog(CMyDialog* pDialog)
{
m_pDialog = pDialog;
}
<p></p>
void CMyClass::SomeUpdateFunction
{
m_pDialog->Invalidate();
m_pDialog->UpdateWindow();
or
m_pDialog->SendMessage(WM_PAINT, NULL, NULL);
or
m_pDialog->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
Notice that I have given you 3 alternative ways to do the update in the update function.
I have made the assumption that Within the CMyDialog class you have defined the CMyClass as follows
CMyDialog header file
CMyClass m_MyClass;
CMyDialog cpp file
BOOL CMyDialog::OnInitDialog()
{
:
m_MyClass.SetDialog(this);
:
return TRUE;
}
Hope that this is clear
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
:-Dyes....thanx for the reply.....
u c to do this.....i have to include CMyDialog.h file in the CMyClass.h file.....
but the CMyClass.h is included in the CMyDialog.h file.....so what happens.....
i get errors.....something like....."';'is missing" and meany unresolved errors.....
statements that didnt have errors before.....
but i like the idea.....
getting the address thru pointers .....never struck me.....
so what i did next was the that all the variables that i needed from the CMyDialog class I had made pointers to get their address and gave to to the CMyClass(using the SetDialog(*var1,*var2,,,,)).....
then what i did is that i BitBlt it in the CMyClass itslf rather than doing it in the CMyDialog.....
funny.....i didnt get any errors or warningz.....but it didnt work.....i meant the windows error box opened up asking whether to debug or sen or not to send the error report.....
any ideas???
thanx a lot.....u helped me lot.....i owe u.....
|
|
|
|
|
I have overloaded the CTreeCtrl::OnCustomdraw ( NMHDR* pNMHDR, LRESULT* pResult )
Function and would like to make the item texts Bold.
Can I use the NMLVCUSTOMDRAW struct. I have tried looking in MSDN.
I successfully have changed the text color with the following code:
<br />
void CSimpleTreeCtrl::OnCustomdraw ( NMHDR* pNMHDR, LRESULT* pResult )<br />
{<br />
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );<br />
pLVCD->clrText = RGB( 210, 65, 20 );
}<br />
Any suggestion how to change the font… ?
_____________________________
...and justice for all
APe
|
|
|
|
|
You just need to select the font into the NMLVCUSTOMDRAW's dc.
You will need to create a member font variable that will be used throughout the life of the control.
NMTVCUSTOMDRAW* pTVCD = (NMTVCUSTOMDRAW*)pNMHDR;
*pResult = CDRF_DODEFAULT;<br>
switch( pTVCD->nmcd.dwDrawStage )
{
case CDDS_ITEMPREPAINT:
{
SelectObject(pTVCD->nmcd.hdc, (HFONT)(*m_pFont));
*pResult = CDRF_NEWFONT;
}
break;
default:
break;
}
I Dream of Absolute Zero
|
|
|
|
|
OK It worked... but...
When making a bold font the text became wider an the last letters in is missing in the text-area... Do you have any cure for that?
_____________________________
...and justice for all
APe
|
|
|
|
|
Hello!
I have tried to apply a style to a message box using a UINT which I then add flags to like:
MB_ICONINFORMATION
MB_ICONEXCLAMATION
MB_ICONQUESTION
MB_ICONSTOP
I also add the button types: MB_OK , MB_RETRYCANCEL , etc.
So I will pass a parameter in to set my style like this:
MB_OK | MB_ICONINFORMATION
I think this should work.
Next I wish to look at the uStyle variable and determine what flags are set in it.
if (uStyle & MB_ICONSTOP)
hIcon = LoadIcon(NULL, IDI_HAND);
else if (uStyle & MB_ICONEXCLAMATION)
hIcon = LoadIcon(NULL, IDI_EXCLAMATION);
else if (uStyle & MB_ICONINFORMATION)
hIcon = LoadIcon(NULL, IDI_INFORMATION);
else if (uStyle & MB_ICONQUESTION)
hIcon = LoadIcon(NULL, IDI_QUESTION);
This does not work like I think it would.
This is what the values are:
MB_ICONINFORMATION;
MB_ICONEXCLAMATION;
MB_ICONQUESTION;
MB_ICONSTOP;
Can someone tell me what I am doing wrong and if there is anywhere I can look to tell me how to work with bitwise flags?
|
|
|
|
|
You have your understanding of the values all wrong; the binary you show is not correct for the hex values. It doesn't make any difference though; your code wouldn't work anyway.
Simply you need to change your code:
if (uStyle & MB_ICONSTOP)
to
if ((uStyle & MB_ICONSTOP) == MB_ICONSTOP)
and similarly in all the other places.
The problem is that the MB_ values do not use mutually exclusive bits. For example, MB_ICONEXCLAMATION and MB_ICONQUESTION both have bit 5 set so (uStyle & MB_ICONQUESTION) will yield non-zero (true) for either.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Phil J Pearson wrote:You have your understanding of the values all wrong
I thought this!
So 0x00000040L == 1000000 not 101000
I had converted decimal to binary instead of hex to binary
Phil J Pearson wrote:
The problem is that the MB_ values do not use mutually exclusive bits.
Yes I thought this was the problem but I did not think of what you suggested, to AND them and compare with the value I wanted!
Thank you
|
|
|
|
|
Hi
It seems like my exe prog. have a memory leak problem. The program read from the lpCmdLine, 6 different files, merges this to one output file and then close.
I close all handle before i Exit.Is there something i have to do, to free memory? I call the exe file 15 times per minute. By the way the program is programmed in Embedded C++, and runs on a CE panel.
Some code:
#include "stdafx.h"
#include "Afx.h"
#include "Winuser.h"
#include "stdlib.h"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
DWORD dwBytesRead, dwBytesWritten, dwPos;
char buff[4096];
TCHAR* filnavn1;
TCHAR* filnavn2;
TCHAR* filnavn3;
TCHAR* filnavn4;
TCHAR* filnavn5;
TCHAR* filnavn6;
TCHAR* filnavnhtml;
DWORD dwBytesRead, dwBytesWritten, dwPos;
HANDLE hFile1, hFile2, hFile3, hFile4, hFile5, hFile6, hAppend;
hFile1 = CreateFile (filnavn1, // Open .txt
GENERIC_READ, // Open for reading
0, // Do not share
NULL, // No security
OPEN_EXISTING, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No template file
//I open 6 files
hAppend = CreateFile (filnavnhtml, // Create output file.
GENERIC_WRITE, // Open for writing
0, // Do not share
NULL, // No security
CREATE_ALWAYS, // Open or create
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No template file
dwPos = SetFilePointer (hAppend, 0, NULL, FILE_END);
do
{
if (ReadFile (hFile1, buff, 4096, &dwBytesRead, NULL))
{
WriteFile (hAppend, buff, dwBytesRead,
&dwBytesWritten, NULL);
}
}
while (dwBytesRead == 4096);
// I do this with all 6 files
//close all files
CloseHandle (hAppend);
CloseHandle (hFile1);
Return 0;
}
Thanks
|
|
|
|
|
gunnar66 wrote:
It seems like my exe prog. have a memory leak problem.
How do you know this?
Are you allocating memory for filnavn1 and filnavnhtml ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
In the CE panel the used memory is growing when my exe prog is running.
I am not allocating any memory for filnavn1 and filnavnhtml
|
|
|
|
|
gunnar66 wrote:
I am not allocating any memory for filnavn1 and filnavnhtml
They are declared as pointers. Shouldn't you be allocating memory for them like:
TCHAR *filnavn1 = new TCHAR[some_size];
...
delete [] filnavn1; Or since they are used for filename purposes, you could just use a stack-based buffer of size MAX_PATH like:
TCHAR filnavn1[MAX_PATH];
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i m trying to convert bitstream file to .MPEG or .AVI ... how can i do that? anybody help me plz ...
pradeep
|
|
|
|