|
I inserted on a form a Picture with a static control and the resource is a bmp image. I put background color when I drawed it at (255,0,255), but I set up the static control as transparent and it draws the background color.
How can make it transparent ?
Thankx !!
|
|
|
|
|
not sure i understand could you explain more
are you trying to draw a transparent bitmap ?
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
exactly. and I put it into a CStatic control as a Bitmap file so it shows it, but the (255,0,255) color in the BMP file doesn't turn to transparent when it is showed into the dialog.
Thankx !!
|
|
|
|
|
I am trying to develop an NT Service, novice in the field and running into following problems.
Let me simplify all the steps to explain problem i am facing, please let me know if i am doing anything wrong
I create a NT Service using Visual Studio 6 ATL Com wizard without a single line of my own code added here. Only thing i change is remove command from Project/Settings/Custom Build that re-registers the service. After that I compile the project. Let say name of the service is MyService. I use following commands to register and unregister service.
MyService -Service
.. start and stop the service
MyService -Unregserver
after this unregserver command this service goes in "Diabled" mode as shown in SCM and now if i want to re-register the service i can "Service cannot be deleted" message box. To only way to register the service again is to logoff the box.
Since I haven't added any of my code in this test project, there shouldn't be case of any dangling handle.
Any ideas?
|
|
|
|
|
It seems your service uninstall handler is not exiting the application after it DeleteService().
And also are you keeping SCM open while doing all these?
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Yes SCM is open while doing all this.
Since I didn't add any code myself in this case and just using wizard generated code, does this mean its a bug in the code that is generated by wizard?
Thanks for response anyway and appreciate any more comments.
|
|
|
|
|
I am having some difficulty and would like some view points on setting up the directory structure of projects that arent so small anymore.
Currently I have three parts to my project. The Core application and the Plugin are dialog based MFC programs.
1) Core Application
2) Common code
3) Plugin Framework
Each in a separate directory. The common code consists of utility functions, drawing routines, etc, which are shared between the core application and the Plugin Framework. One of my problems is that the MFC header file stdafx.h are all the includes for MFC stuff like CString. I don't want to hard code the path from the common directory back to my current project directory.
For example a file in the common directory needs to use CString but does not know what it is. I don't want to have to do this because I think it is bad technique.
#include "d:\project\stdafx.h"
I also don't want to do this
#ifdef CORE_APP
#include "d:\project1\stdafx.h"
#else
#include "d:\project2\stdafx.h"
#endif
As a result of moving all the files around I am now getting CString access violations and I am guessing it must have something to do with my poor file structure.
So what is a good approach for separating common files like in my situation?
Hope that made sense.
|
|
|
|
|
Use include directories? Just specify these in the properties.
|
|
|
|
|
I did add an include for the common folder but how do files in the common folder see the stdafx.h for example in the project directory or is that bad technique.
So, if I include #include "stdafx.h" the files in the common directory can't find this file (duh). I guess I could add a file in the common directory called includes.h and include anything that the common files need.
|
|
|
|
|
Access violations should have nothing to do with your file structure at all.
Are you using threads?
John
|
|
|
|
|
That's what I would of thought as well.
I am not using any threads. Well, I am using MSXML4 using smart pointers so I don't know what's going on in the background nevertheless the project was working just fine. I recently had a working project and decided that I wanted to clean up the code and reorganize the file structure. I added nothing new during this cleaning up process so it can't be anything I added.
I did things like:
Changed this from:
int A,R,G,B;
to this:
struct _Color
{
int A,R,G,B;
};
and
CString Fontname;
CString Fontstyle;
float Fontsize;
int A,R,G,B;
to
struct _Font
{
float Size;
CString Name, Style;
_Color Color;
};
I changed the way I included some of my file around and now the very first CString I get to I get the following error.
First-chance exception in HTPCCORE.exe (MFC42D.DLL): 0xC0000005: Access Violation.
crashing in the = operator
const CString& CString::operator=(const CString& stringSrc)
{
if (m_pchData != stringSrc.m_pchData)
{
crashs here-> if ((GetData()->nRefs < 0 && GetData() != _afxDataNil) ||
stringSrc.GetData()->nRefs < 0)
{
// actual copy necessary since one of the strings is locked
AssignCopy(stringSrc.GetData()->nDataLength, stringSrc.m_pchData);
}
else
{
// can just copy references around
Release();
ASSERT(stringSrc.GetData() != _afxDataNil);
m_pchData = stringSrc.m_pchData;
InterlockedIncrement(&GetData()->nRefs);
}
}
return *this;
}
Makes no sense.
If I were using threads what would the solution be. Oh, I am using VC++6 and I recently installed the latest service pack. Things were still working then as well.
|
|
|
|
|
My thoughts are that you did not initialize something in your first version properly but you were lucky that it did not cause a problem.
John
|
|
|
|
|
That may be the case. I started a new empty project and slowly added in all my files and checking for things like uninitialized variables. It works fine again. I really did not change much beside using a new empty project. Thanks for your responses.
|
|
|
|
|
smesser wrote:
So what is a good approach for separating common files like in my situation?
Exactly what you did. You can also seperate each part (execpt for the main application) into is own library or dll.
John
|
|
|
|
|
The plugin is a dll I need to learn how to put common into a dll. Can you point out a good article?
|
|
|
|
|
My help files are split in 4 .chm (one master, linking to others)... I want to search topic by ids without the user know that the topic doesn't come from the main .chm ?
I used
HtmlHelp(GetDesktopWindow(), HelpPath, HH_DISPLAY_TOC, id);
when I had only one .chm
but now I don't have an idea how to do the same!
thanks
|
|
|
|
|
I am trying to wrap a C API in C++. The problem I am having is that some of the functions in this API are callbacks. When I create functions in a C++ class the calling convention is __thiscall. From each function I created I called the corresonding C function from the API. The problem is that the C function uses the __cdecl calling convention. I get an error when trying to compile
cannot convert parameter 2 from 'void *' to 'void (__cdecl *)(void *)'
Ex.
// this is the callback
void CTest:: Error(void *Param)
{
}
CNew new; // in the CTest class
new.AppCatchError(Error) //this is within the CTest class
void CNew::AppCatchError(void* HandlerFunc)// HandlerFunc a c++ member function
{
//this is the C API function
AppError(HandlerFunc); //error this is looking for a c function __cdecl
}
|
|
|
|
|
If you pass a function pointer along with another function, you need to create a typedef of it's "signature" sorta say.
it'd be something like this:
typedef void (__cdecl *FuncPtr)(void *);
This basically defines a generic function signature, with C declaration and one void ptr argument.
And now use FuncPtr as argument for AppCatchError in order to be able to pass Error() along as a pointer.
Hope this helps.
If you're interested to know more about it, check this out
|
|
|
|
|
Still geting an error
cannot convert parameter 2 from 'void (__cdecl *(void))(void *)' to 'void (__cdecl *)(void *)'
This has to do with the fact that it is a member function. How does this work in C++, if this function was global function there wouldn't be a problem.
|
|
|
|
|
You can do three things:
1) Make the function global
2) Make it static
3) Wrapper functions
|
|
|
|
|
gs1589 wrote:
This has to do with the fact that it is a member function.
Yes, it does. If you want to use it this way the member function must be a static member function.
John
|
|
|
|
|
Error(void *Param) is a member function. Make it static.
// this is the callback
static void __stdcall CTest:: Error(void *Param);
Kuphryn
|
|
|
|
|
Hi,
I have a couple of list views in which I use Custom Draw to get my content on screen. This all works just fine, except for one thing. The uItemState member of the NMCUSTOMDRAW structure is supposed to indicate whether an item is selected or not.
I would test it like:
if( pNMCD->nmcd.uItemState & CDIS_SELECTED)
{
}
Except that always ends up being true, even when an item is not selected. So, right now I'm testing the MFC way with GetItemState, and test for the LVIS_SELECTED bit. But am I just using uItemState in a wrong way or anything? Everywhere I look at on the web it's used in such way..
It's not a big thing, I mean, GetItemState does the job. But I am getting curious why it won't work for me.
|
|
|
|
|
uItemState is only valid for certain draw stages, as specified by the uDrawStage member of NMCUSTOMDRAW .
Software Zen: delete this;
|
|
|
|
|
I want to create CBitmapButton in a dialog with CButton::Create(), but for some reason the button is not visible when I run the app.
I put the following code in CDialog::OnInitDialog()
<br />
VERIFY(m_whiteBtn2.Create("", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_OWNERDRAW, CRect(200, 100,85,48), this, IDC_WHITE_BUTTON2));<br />
<br />
VERIFY(m_whiteBtn2.LoadBitmaps(IDB_WHITE_BUTTONU, IDB_WHITE_BUTTOND));<br />
Does anyone know what might be the problem?
|
|
|
|