|
I need help with writing something in my resource file to a file. For example, i have a .scr file (screen saver) in my resource file so its packed along with my program. Now when the program is run i want to write that resource back to a file (it's a matter of keeping everything in one executable really). Does anyone know how to do this?
Kuniva
|
|
|
|
|
Use LoadResource and related APIs to extract the resource and then your favorite file-managing APIs to write the resource to a file.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Are you writing a virus perchance? I hope not.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
yes, i am, me, the most idiotic c++ programmer of all times who is only 16, is going to write a network-born hydra virus which will write itself onto your harddisk in a dark and secret place where you will never find it and it will give me access to all your files, MWAHAHAHA!
lol, BTW i was only kidding
i wouldn't be able to write a program that lists the prime numbers let alone something like that.
And if you must know what its for: i have alot of screensavers (i'm a collector) and i want other people to be able to enjoy them too and i want to have a backup if my harddisk gets erased (by some virus perhaps lol) so i thought i'd write a program which will pack all my screensavers in an exe and install them automatically (it'll also detect if you got win98, win2000 or winNT and i might add some themes too thats why i dont just zip 'em + its cooler) :p
Kuniva
|
|
|
|
|
- I want to return an array from a function. But it has errors.
- Such is my code:
int[2] f()
{
int a[2]= {1,2};
return a;
}
void main()
{
f();
}
- How to return an array? Can you help?
- Regards,
BigMouth
|
|
|
|
|
You cannot because you're returning a reference (an implicit pointer) to your local variable a , which is created on the stack and disappears as soon as the function exits.
Basically, you have two solutions:- Create the array on the heap with
int a[]=new int[2]; Remember the array has to be deleted when no longer necessary with delete [] a;
- Use some high-level class like
std::vector<int> .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
- Thanks pal!
- I modified my codes like this, but is still has errors.
int[2] f()
{
int a[]=new int[2];
a[0]=1;
a[1]=2;
return a;
}
void main()
{
f();
}
- Can you help?
- Regards,
BigMouth
|
|
|
|
|
You should do it with pointers like this
void f( int *a)
{
a= new int [2];
return;
}
void main()
{
int *a;
f(a);
delete a;
}
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Aarrrg...
No way!
void f(int** a)
{
*a = new int[2];
}
void main()
{
int* a = 0;
f(&a);
delete [] a;
}
|
|
|
|
|
- Thanks pal!
- You are very smart.
- Regards,
BigMouth
|
|
|
|
|
- Thanks pal!
- You help me a lot!
- Regards,
BigMouth
|
|
|
|
|
C does not allow you to explicitly return an array, like you can in Java. What you can do is return a pointer which points to the beginning of an array.
int* f()
{
int* a = new int[2];
a[0] = 1;
a[1] = 2;
return a;
}
void main()
{
int* a = f();
delete [] a;
}
Notice that int[2] turned into int*. Also notice that I converted "a" to a dynamic array since it needs to hang around longer than the scope of the function (f). Then in main I call delete to free the memory. If not, I'll have a memory leak.
Regards,
Alvaro
|
|
|
|
|
- Thanks pal!
- You are very smart.
- Regards,
BigMouth
|
|
|
|
|
I have no response to my question ("HICON in extension DLL").
So I decided to make my problem simple:
How can I create an HICON from a CBitmap object considering transparent color?
{
...
CBitmap bmResourceBitmap;
HICON hIconTarget;
<BR>
hIconTarget = <FONT COLOR="Green">
...
}
A Gift
Download MIDI
|
|
|
|
|
One possible way is to Bitmap -> ImageList -> Icon
CImageList m_imgIcon;
m_imgIcon.Create(32,32,ILC_COLORDDB |ILC_MASK,0,10);
CBitmap bm;
bm.LoadBitmap(IDB_ICON);
m_imgIcon.Add(&bm,RGB(255,0,255));
HICON hIcon;
hIcon = m_imgIcon.ExtractIcon(nImg);
|
|
|
|
|
Thank you very much for your solution
|
|
|
|
|
Use ::CreateIconIndirect . Didn't try it myself, but seems to suit your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you very much for you solution.
|
|
|
|
|
There is a catch with this, I know this cause I just finished writing some bmp to icon converter code at home - if you want the code just email me, the problem is the ICONINFO structure need two HBITMAPs, the first or the hbmColor can be created how ever you want, 8 bit, 16 bit, etc. But the second HBITMAP MUST be created as a 1 bit bitmap if you want the mask to work right (at least that was the only way I got it to work correctly). And once you have created a the bitmap you iterate through the bits a little differently than normal since each bit represents a pixel. The code I wrote handles conversion from a 32bit HBITMAP to an HICON. you can email me at ddiego@one.net if you want the code
|
|
|
|
|
Hi !
I have a ListView app, in which I want to implement drag'n drop to allow the user to move the listed objects.
I tried to find where to start. In the MSDN, I only found info about drag'n drop between different app using OLE, but in my case, I want to have drag'n drop only in my own app.
Anyone could give me some hints on where to start ?
Thank you !
Jerome
|
|
|
|
|
Check the Drag & Drop area at CodeGuru Listview Control section. There're at least two articles on the subject.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
when i use setwindowtext(),the title has often been changed automatically,why?
|
|
|
|
|
The Child Windows of MFC use the title of the associated document as the title of the window frame (automatically). To change the title of the window frame, all you need to do is change that in the document using :
pDoc->SetTitle(WHATEVER_YOU_WANT);
and you should notice that the title in the window frame has been automatically updated to reflect this.
P.S. make sure you get the active document (pDoc) by using the GetActiveDocument() member function of the CHILD frame or view.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
thanks!
now i have only one document, and three views,
how i do it?
|
|
|
|
|