|
Kharfax wrote: im using Update Resource to change a Bitmap in a DLL. The bitmap is beign changed, but the new added bitmap hasn't a valid format.
Get the bitmap's format fixed first before moving on to UpdateResource() . It doesn't make sense to update a resource via UpdateResource() when the resource is not even vaid.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Maybe I didn't explain myself well :S
If I add the new bitmap in the project via Visual Studio, it works great.
The problem is when I load the same bitmap, a .bmp file, into memory and then add it to the DLL using UpdateResorce.
The new bitmap replaces the old, but Visual studio tell me that the resource had an invalid format and dont show me the image, Loadbitmap also fails the load and shows me an empty static control in my test app.
|
|
|
|
|
I´m not sure, but try to check the EXACT format of ur bitmap.....I had the same prob with a GIF file and after checking the exact properties of the working image and after moving my properties to match them exa ctly it worked.....if it looks the same it isnt necessarily the same for VS
|
|
|
|
|
mmm, I don't understand, maybe I missing something...
I have a static control, and I set a Bitmap resource in it using SetBitmap(), that way, I can see the image.
If I add the resorces bmps using visual studio, it work fantastic.
But when I use UpdateResource to change the Bitmap, for another working bitmap made with VS also, it fails, and I don't see anything.
So I open the DLL to check if the resourse was added and I find it's there, but when I try to see it, VS tell me it has an invalid format.
So... The question would be, the bitmap stored as resourse is changed in some way?
Should I write the lenght of the resource at the beginning?
Actually I'm doing an exact copy of the file to the resource, and I also tried writing the lenght and removing the BM at the beginning, but nothing works.
I dont understand what you mean with "check the EXACT format of the bitmap"
|
|
|
|
|
hi
try this. First put a bitmap to your resource file using VS . then change that resource. next put the same bitmap using updateresource api. save that resource also. try comparing it. and try to catch out which bytes are missing ? This might lead you to a solution , i hopes
regards
krishnan
If u can Dream... U can do it
|
|
|
|
|
Good idea pal, I'll try and see what happens, thanks
|
|
|
|
|
I found the solution to this problem.
When you add a RT_BITMAP type resorce, the function UpdateResorce() adds a 14 Bytes header, I belive those bytes are a normal BMP header, so what I did is not copying those 14 bytes, and all worked great
<br />
char* buf = (char*)HeapAlloc (GetProcessHeap(), 0, dwBytesRead);<br />
memcpy (buf, lpBuffer + 14, dwBytesRead - 14);<br />
MSDN really sucks.
Thanks a lot for the feedback people
|
|
|
|
|
Hello All,
Suppose I have a class
class A
{
public:
void foo1 ();
//Other functions (possibly virtual)
private:
//private members go here
}
and I have a structure
struct S
{
A member1;
//Other members go here
}
what will be the effect of
struct S struc1;
struct S struc2;
1. memcpy (&struc1, &struc2, sizeof (S));
2. memset (&struc1, 0, sizeof(S));
I feel the memcpy should pose no problems but what about memset? What will happen to the virtual function table of the class?
Thanks in advance!
----------------------------------------------
If you need a hammer get C and shut up. If you need a nail gun get C++ and shut up. If you don't need *those* things (and good design should tell you) then by all means get a factory, factory, factory.
--code-frog@codeproject
----------------------------------------------
Why would you need to date, when C++ is your soul mate?!
--Steve Echols@codeproject
----------------------------------------------
|
|
|
|
|
if you memset all A member to '\0', you gonna delete the A class virtual table, ,but that wont crash. it will crash only when a virtualized function gets called, because the adresse of the mapping table can't be reached (trying to access NULL address)...
|
|
|
|
|
In your example both memcpy and memset would be fine.
You have no virtual methods (so no vtable), nor have you specified A/S as having any other complex data types.
If A/S has even 1 virtual method then, as mentioned, memset will hose the vtable.
Likewise if A/S contains any pointers to other A/S objects then memcpy will likely screw them up.
You can likely get around the memset problem by following it with a placement new call.
e.g.
memset(&struc1, 0, sizeof(S));
new(&struc1) S;
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Since you are already using C++, there is no need to initialize nor copy your structure in the way you describe. struct in C++ is no different from class with the exception that its default protection is set to public . Knowing that, you should write your code as follows:
class A
{
public:
A();
A(const A& a);
A& operator= (const A& a);
void foo1();
private:
};
struct S
{
S();
S(const S& s);
S& operator= (const S& s);
A member1;
};
void main()
{
S s1;
S s2 = s1;
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
....for all the replies!
----------------------------------------------
If you need a hammer get C and shut up. If you need a nail gun get C++ and shut up. If you don't need *those* things (and good design should tell you) then by all means get a factory, factory, factory.
--code-frog@codeproject
----------------------------------------------
Why would you need to date, when C++ is your soul mate?!
--Steve Echols@codeproject
----------------------------------------------
|
|
|
|
|
I have a Visual C++ 2005 MFC dialog application that minimizes to a task tray icon on clicking "X". I'd like to be able to change the tooltip message which you see when you hover over the icon dynamically whenever a certain value changes, in my case, temp of a cardbus device.
Right now it just displays the applications name because that's what I entered when i created the icon using this call:
TrayIcon->Create(0, nTrayNotificationMsg_, L"App Name",
m_hIcon, IDR_SYSTRAY_MENU);
Thanks for any help or links.
|
|
|
|
|
I'm sure exactly how this is done in MFC, or if you have used some VC2005 wizard for the minimize to tray feature. But when we minimize an app to the tray we need to create a NOTIFYICONDATA which contains all the info (icon, tooltip etc) then we use the Shell_NotifyIcon() function to add it to the tray. In your case you want to uppdate the tray icon, so you should use the Shell_NotifyIcon() function with the NIM_MODIFY flag.
|
|
|
|
|
waldermort wrote: I'm sure exactly how this is done in MFC,
AFAIK, there is no class associated with same in MFC!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Well that surprised me, there seems to be a class for everything else
|
|
|
|
|
After reading the article:
Enumerating processes : A practical approach By Irfan Dawood.
I found this really helpfull with what I have to do.
However, I only have the name of the application (hello.exe). The processInfo=new PROCESSENTRY32; has a member variable: szExeFile which is a:
"Pointer to a null-terminated string that specifies the name of the executable file for the process. "
I figure after getting all the processes if I just search for my process using the name I can obtain the process ID of the "hello.exe" process therefore then be able to set the priority:
HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,TRUE,processID);<br />
if(hProcess==NULL)<br />
{<br />
cout<<"Unable to get handle of process: "<<processID;<br />
cout<<"Error is: "<<GetLastError();<br />
return 1;<br />
}<br />
<br />
cout<<endl<<"Priority Class: "<<GetPriorityClass(hProcess);<br />
SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS);<br />
CloseHandle(hProcess);
but whenever I try to do: if( processInfo->szExeFile == _T("hello.exe")) it doesn't work. and when I try to print out cout<<endl<<"Name: "<<processInfo->szExeFile; I get "Name: 0036630C"...
Am I completely off my rocker?
Thanks,
-- modified at 11:36 Thursday 24th August, 2006
-- modified at 11:44 Thursday 24th August, 2006
Kitty5
|
|
|
|
|
kitty5 wrote: but whenever I try to do: if( processInfo->szExeFile == _T("hello.exe")) it doesn't work. and when I try to print out cout<<endl<<"name: "<<processinfo-="">szExeFile; I get "Name: 0036630C"...
processInfo->szExeFile is a pointer. When you try comparing it or print it you are really testing the address. You should de-reference it first ie
if( *processInfo->szExeFile == _T("hello.exe"))
cout<<endl<<"Name: "<<*processInfo->szExeFile;
|
|
|
|
|
Hi I would like to make a program that ginen a wave file it filter (bandpass or low and Hi) and play the sample. It's possible? How?
I'm trying to: make FFT -> cut the frequency -> make a IFFT -> then play.
For FFT and IFFT for example I can use this code:
http://www.codeproject.com/cpp/howtofft.asp[^]
But the I load a wave the samples for second it's non a multiple of 2 and no FFT is possible. How can I do?
|
|
|
|
|
ilFrate wrote: But the I load a wave the samples for second it's non a multiple of 2 and no FFT is possible. How can I do?
I think you add/remove some samples to the data set to make it a 2^n one. I don't remember the details though.
Best,
Jun
|
|
|
|
|
Yes, but how resample without distort the wave or without lose too much quality?
|
|
|
|
|
I get LNK2005 errors with the static CRuntimeClass datamember of the specialized template
Why?
I simplified the classes to highlight the problem.
TXBase contains special algorithms and also the CRuntimeClass functions and static classTXBase to make RUNTIME_CLASS things work.
////////////////////////////////////////////////////////////
// TXView template
////////////////////////////////////////////////////////////
#undef CLASS_NAME
#define CLASS_NAME classTXView_##BASE
template < class BASE >
class TXView : public TXBase < BASE >
{
public:
TXView(UINT nIDTemplate = 0);
virtual CRuntimeClass* GetRuntimeClass();
static const CRuntimeClass CLASS_NAME;
};
template < class BASE > TXView< BASE >::TXView(UINT nIDTemplate /*= 0*/)
: TXBase< BASE >::TXBase(nIDTemplate)
{
}
template < class BASE > const CRuntimeClass TXView<base />::CLASS_NAME =
{
"TXView", sizeof(class TXView<base />), 0xFFFF, TXView<base />::CreateObject,
TXView<base />::_GetBaseClass, 0
};
template < class BASE > CRuntimeClass* TXView<base />::GetRuntimeClass()
{
return (CRuntimeClass*)&TXView<base />::CLASS_NAME;
}
/////////////////////////////////////////////////////////////////
// Specialized template for FormView
/////////////////////////////////////////////////////////////////
#undef CLASS_NAME
#define CLASS_NAME classTXView_##CFormView
template <>
class TXView < CFormView > : public TXBase < CFormView >
{
public:
inline TXView(UINT nIDTemplate = 0);
inline virtual CRuntimeClass* GetRuntimeClass();
static const CRuntimeClass CLASS_NAME;
};
template <> inline TXView< CFormView >::TXView(UINT nIDTemplate /*= 0*/)
: TXBase< CFormView >(nIDTemplate)
{
}
template <> const CRuntimeClass TXView<cformview>::CLASS_NAME =
{
"TXView", sizeof(TXView<cformview>), 0xFFFF, TXView<cformview>::CreateObject, &TXView<cformview>::_GetBaseClass, 0
};
template <> inline CRuntimeClass* TXView<cformview>::GetRuntimeClass()
{
return (CRuntimeClass*)&TXView<cformview>::CLASS_NAME;
}
Thanks if you can help!
|
|
|
|
|
Hello
I´m inserting a bitmap image in my dialog with a picture control, and i want it
to be transparent like when you insert an icon in a dialog, and you set the background
colour to some kind of green at visual studio icon editor and it do the trick.
So, what background color should I use with bitmaps?
btw I´m using Visual Studio 2003 IDE.
thank´s.
-- modified at 8:53 Thursday 24th August, 2006
|
|
|
|
|
This is a little work:
http://www.codeproject.com/staticctrl/LayeredBitmapCtrl1.asp
or look yourself for "transparent"
Greetings from Germany
|
|
|
|
|
There ia a GDI function called TransparentBlt() , but it is not very good. The best approach is to use two bitmaps. The first should be black in all areas you want transparent and white in all other areas. The secon, your picture, should be white in all areas you want transparent. You draw these two over the top of each other. The fist bitmap using BitBlt() with SRCAND , the second using BitBlt with SRCPAINT . The result is a transparent bitmap.
|
|
|
|