|
- 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?
|
|
|
|
|
|
the hwnd should be a member var. of the CFileDialog - Class (m_hwnd)
if you want to get the path of the selected file use CFileDialog::GetPathName
or if you have got multiple selection you have to use CFileDialog::GetStartPosition and CFileDialog::GetNextPathName
hope this helps
bernhard
"There are three roads to ruin: women, gambling and technicians. The most pleasant is with women, the quickest is with gambling, but the surest is with technicians." Georges Pompidou
|
|
|
|
|
i want to make the main window invisible at the start of my application.my program is dialog based MFC application.
how to? thanks.
|
|
|
|
|
Set a timer in your InitDialog [say a 3 second timer]
Now the timer gets called [after 3 seconds]
ShowWindow(SW_HIDE) and remove the timer
Nish
p.s. putting ShowWindow(SW_HIDE) in InitDialog won't work cause of the manner in which modal dialogs are created and shown on screen
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Unselect the "Visible" style at the dialog resources properties tab, add a BOOL m_bFirstShowWindow variable to your CDialog -based class, initialize m_bFirstShowWindow to TRUE on construction time, and add the following message handler for WM_WINDOWPOSCHANGING :
void CYourDlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
CDialog::OnWindowPosChanging(lpwndpos);
if(lpwndpos->flags&SWP_SHOWWINDOW){
if(m_bFirstShowWindow){
m_bFirstShowWindow=FALSE;
lpwndpos->flags&=~SWP_SHOWWINDOW;
}
}
} Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry to trouble you again.
I can't find the WM_WINDOWPOSCHANGING message in the Class Wizard.so i don't know how to add the message handle function.
How can i generate the function OnWindowPosChanging?
tank you.
|
|
|
|
|
Sorry to trouble you again.
No problem
MFC Class WIzard -> Class Info tab -> Advanced Options -> Message filter -> Window
This message filter thing is IMHO a little annoying and a constant source of confusion.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|