|
It should be something like:
class CMyClass
{
virtual int MyFunction(int parameter1, int parameter2, ....) = 0 ;
} ;
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Hi, I've got some code to make a window transparent
void CMainWindow::FadeWindow(int percentage)
{
OSVERSIONINFO osvi;
GetVersionEx(&osvi);
if (osvi.dwMajorVersion>=5)
{
lpfnSetLayeredWindowAttributes SetLayeredWindowAttributes;
HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL"));
if (!hUser32)
return;
pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes");
SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
pSetLayeredWindowAttributes(*this, 0, (percentage*255)/100, LWA_ALPHA);
}
}
void CMainWindow::DisableFade()
{
OSVERSIONINFO osvi;
GetVersionEx(&osvi);
if (osvi.dwMajorVersion>=5)
{
SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd,GWL_EXSTYLE) & ~WS_EX_LAYERED);
}
}
My problem is that I want the window to be transparent only while dragged (when the user clicks on the window caption); I tried overriding WM_NCLBUTTONDOWN and WM_NCLBUTTONUP, but I never receive the WM_NCLBUTTONUP, so my window stays transparent,in order to get the WM_NCLBUTTONUP, I added a SetCapture(), but then I can't drag the window any more.
Does anyone have an idea?
Thanks,
John
|
|
|
|
|
Take a look at this
http://codeguru.earthweb.com/misc/wm_nclbuttonup.html
Sorry CP!
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Thanks, looks like exactly what my problem is.
But isn't there a way to do that without any hooking procedure?
|
|
|
|
|
Take a look at the comments section at the bottom. I beleive someone posted a way that doesn't use hooks.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Damn, I didn't see the comment at the bottom of the page,
Looks far more cleaner
Thanks
|
|
|
|
|
Hi,
I wonder if, making addref and release in the Unknown pointer here is right or not ? ( or bad made...)
STDMETHODIMP CSCurveMeta::GetCloneDoc(LPUNKNOWN *XMLDoc)
{
*XMLDoc = _pXMLClonedDoc;
XMLDoc->AddRef();
return S_OK;
}
And the call:
CComQIPtr<MSXML2::IXMLDOMDocument2> _pXMLClonedDoc;
...
hr = pBsMetafile->GetCloneDoc(&pUnk);
_pXMLClonedDoc = pUnk;
pUnk->Release();
Is it wrong ?, Why yes or no ?, thanks in advance
Braulio
|
|
|
|
|
Yes and yes. Both are correct.
Here are some general rules about addref/release. A lot of it is based on the idea of borrowing an interface and owning an interface.
1. When an interface is passed to another routine, the routine need not invoke AddRef UNLESS the interface is going to be saved and later used outside of the scope of the invocation.
The idea here is that the calling routine already owns the object (by having a ref). Thus, the routine being called temporarily borrows ownership of the object while it is executing.
2. When an interface is returned to a calling routine, the routine returning the interface MUST AddRef the object. Then when the calling routine is done with the interface he should Release unless the interface is being saved for later use.
The idea in this case is that when the routine being called returns, he must either give the ownership of the object to the calling routine (by not calling AddRef) or share ownership with himself and the caller by invoking AddRef.
You code is a perfect example of point #2. The routine being called AddRefs the object to be returned. The calling routine saves a copy of the object (which due to how CComQIPtr works also does an AddRef) and then releases the returned interface.
So after all is said and done, _pXMLClonedDoc in both objects still maintain a reference.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Thanks a lot, this helps me a lot to understand all the "dark" rules of COM
Greetings
Braulio
|
|
|
|
|
It doesn't look like you're cloning your doc, but rather just adding to the ref count. You will not get a pointer to a new object, but another pointer to the original doc.
|
|
|
|
|
Thanks for the tip, but that´s what I want to do, sorry for the "Clone" name it seems a little bit strange outside it context.
What I have is an XML Doc that holds the properties, the XML Clone method, holds a copy to the original XML Doc, so I want to share that pointers with all the property pages, then I can make all the modification in the property pages, and if the user presses apply, just copy the clone to the original.
Greetings
Braulio
|
|
|
|
|
If I have an array:
double xcoord[80];
I can pass it to a function and the function can receive it as a pointer...
void AcceptArray(double* )
but how do I write the function prototype if that array were multidimensional, say -- xcoord[80][10]
|
|
|
|
|
Send it in as you would with a single dimensional array:
void AcceptArray(double *array)
but when you use it inside of your function, calculate the index that the two values would point to:
// access array[x][y],
array[(y * width) + x ]
where width is the number of columns, or x values in one row.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
okay, I have this array:
double x_coord1[80][10];
this is one of my function prototypes:
void NewCoordinates(double* xcoord1, double* ycoord1, int global_numcoord1, double* x_coord1, double* y_coord1);
and when I call on the function like so:
NewCoordinates(xcoord1, ycoord1, global_numcoord1, x_coord1, y_coord1);
I get this error:
C:\Windows\Desktop\QE2 heart program\TestGLView.cpp(460) : error C2664: 'NewCoordinates' : cannot convert parameter 4 from 'double [80][10]' to 'double *'
what am I doing wrong?
|
|
|
|
|
I am sorry, I was writing a test program to make sure that I gave you good advice, and I was distracted in the middle. When I came back to write my message to you, I assumed that the code that I got was working.
Woods13 gives the correct way to do it:
double x[][80]
or
double **x
The way that I suggested is for dynamic arrays that are declared like this:
double x[20 * 80];
then your array is one dimensional.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
void AcceptArray(double var[][10]) ;
That should do the trick.
//------------------------
CSignature::Jeff() ;
PostMessage(WM_QUIT) ;
//------------------------
|
|
|
|
|
void Accept2DArray (double **);
HTH
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
Hi,
I want to collect the system small icons (typically 16x16 pixels; showing at the left within a windows´ titlebar) from any application into a bitmap stripe. "ExtractIcon" works only for system large icons (typically 32x32 pixels).
Does anyone know how to get at the HICON?
Best regards,
Amar
|
|
|
|
|
Try LoadIcon
Best regards,
Alexandru Savescu
|
|
|
|
|
Thanks, Alexandru,
but... I have found this in MSDN Library:
"LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values."
SM_CXICON and SM_CYICON correspond to 32x32.
Any other idea?
Amar
|
|
|
|
|
try LoadImage() . Note that you'll first have to load the module (dll or exe) into memory in order to have a handle to pass in.
Developers that like shiny objects also dig case mods and scratch-and-sniff stickers. Klaus Probst, The Lounge
|
|
|
|
|
I try..
HICON hiChild16 = (HICON)::LoadImage(NULL, pszAppDir, IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
... but this returns always a NULL pointer.
pszAppDir contains the path and filename of the desired application.
What do I wrong?
Amar
|
|
|
|
|
An application is not an icon file. However, an application can have icons in it's resources. You need to load the application into memory (try LoadLibrary() ) and then pass the HINSTANCE returned from that into LoadImage() . You'll also have to specify the resource ID of the icon.
Alternately, you could use ExtractIconEx() . Check out this article for an example.
Developers that like shiny objects also dig case mods and scratch-and-sniff stickers. Klaus Probst, The Lounge
|
|
|
|
|
Many, many thanks, Shoq9!!!
With "ExtractIconEx" it works perfectly!!!!
Amar
|
|
|
|
|
Many icon contain 16x16 sub-icons,Use Icon Searcher to collect system icons.
Icon Searcher performs fast scan of all local hard
disks for icon images(Support XP style icon). The
program handles lots of different file formats,
like DLL, EXE, ICO, ICL, OCX ,SCR, CPL ,BPL and
extracts all available icons from files to the user-friendly visual image list.
|
|
|
|