|
I have to load a .png image on my button. Can some one please help me out how I can do this in MFC.
Thanks in advance..
|
|
|
|
|
You can load PNG images using CImage[^] class.
Another option is a GDI+ Bitmap[^] class.
And if you are using MFC 9.0.30411 or later, you could also use a CPngImage[^] class.
|
|
|
|
|
Thanks for ur reply, can u please provide me some code example..
Thaks a lot
|
|
|
|
|
My code is like this :
CImage C_PngImage;
PngImage.Load(_T("c:\\123.png"))
but I don't know how to load on the button.
Can u please now what to do next.
Thanks
|
|
|
|
|
AbhiHcl wrote: but I don't know how to load on the button.
You mean load the image on a button click event or load the image and display it on a button (image button)?
|
|
|
|
|
I mean load the image on the button drawitem().
|
|
|
|
|
In that case I'd suggest you read this[^] article about buttons that support PNG files with transparency.
You could use the class provided in the article directly or
you could investigate the source code to see how it works.
|
|
|
|
|
How to find the average, worst complexity of a code??
say for ex,
for i= 1 to n
{
}
for j= 1 to i
{
x=x+1
}
Please help me ..
|
|
|
|
|
Huh?
Did you bother looking at your post? Notice anything "strange" about it?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You have to claculate from your program; for this example
first for loop execute "n" times and second loo execute n times because value of "i" is "n"
suppose "T1" time need to execute one iteration in the first for loop and "T2" time needs for one iteration in second loop
so it take T1*n + T2*n that is an order of n, ie it depend on input variable "n"
This is the time complexity
|
|
|
|
|
Hai Radhakrishnan,
Thanks for your responce. Can you come again to tell me how it can be represented in Big O notation...
|
|
|
|
|
O(n) ?
Watched code never compiles.
|
|
|
|
|
Yes it is the order of n O(n)
|
|
|
|
|
Hi All,
Im working on transcoding media streams using ffmpeg.
And,I am using av_open_input_file to open the video file.
But,It always fails.
Can anybody help me?
|
|
|
|
|
gmallax wrote: But,It always fails.
This sort of problem description really does not mean anything. If your program fails then you need to explain exactly what error messages or exceptions you see. Only then can anyone begin to guess what may be wrong.
It's time for a new signature.
|
|
|
|
|
Did you call av_register_all() ? It's like CoInitialize, you need to call it before calling anything else.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hiya,
It would be helpful if someone tell me how I could convert ostringstream to tchar* such that it will work in both ansi and unicode compilation. currently i have done like:
std::ostringstream strn;
strn <<"Just do it!";
const TCHAR* tata = static_cast< LPCTSTR >(strn.str().c_str());
But this does not seems to work in both the cases.
|
|
|
|
|
I'd use something like:
#ifdef _UNICODE
typedef std::wstring tstring;
typedef std::wostringstream tostringstream;
#else
typedef std::string tstring;
typedef std::ostringstream tostringstream;
#endif
tostringstream strn;
strn << _T("Just do it!");
tstring str = strn.str();
const TCHAR* tata = str.c_str();
modified on Wednesday, May 12, 2010 8:48 AM
|
|
|
|
|
Hi, I have an owner-drawn static control that I use to display a file path. The file path often exceeds the width of the static control and the last directories and files are truncated.
I know about PathSetDlgItemPath and PathCompactPath, but they don't work with this control because it is owner-drawn (the app is skinned). I've looked at PathCompactPath, but it requires a HDC parameter for reference, and the drawing is done with Gdiplus. The control draws itself in the OnPaint routine with this code:
void CNiceLabel::OnPaint()
{
CPaintDC dc(this);
CRect r;
GetClientRect(&r);
auto_ptr<Graphics> g(Graphics::FromHDC(dc.m_hDC));
CStringW txt;
GetWindowText(txt);
Gdiplus::Font myFont(m_FontName, (REAL) m_FontSize, m_FontStyle);
StringFormat format;
RectF rf;
g->MeasureString(txt, txt.GetLength(), &myFont, PointF((REAL) r.left, (REAL) r.top), &rf);
if (m_bWordWrap)
{
rf.Width = (REAL) r.Width();
rf.Height = (REAL) r.Height();
}
Color color;
color.SetFromCOLORREF(m_Color);
SolidBrush whiteBrush(color);
g->DrawString(txt, txt.GetLength(), &myFont,
rf, &format, &whiteBrush);
g->Flush();
}
I thought about using g->GetHDC() to obtain a HDC for PathCompactPath to work with, but I probably need to select the font in it, and the font I use for drawing is a Gdiplus::Font, not CFont. And it can't be selected - it is passed to DrawString directly as a parameter.
So I'm looking for a way to make PathCompactPath work with my control, or if someone can point me a function that does a similar job but has its source code published, that would be great.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi,
How can i get file status(ie. open, close, edit) using C or C++. Is there any API in windows.
Thanks in advance
Suzu
|
|
|
|
|
A file is either opened or closed by one or more processes. The mode in which it is open is a characteristic of the handle, which is owned by a process, not the file. (not all handles are owned by processes, but let's keep this simple.)
The bad news is: there is no API. You could have a go at the object manager[^] name space, but this requires the openfiles global flag to be on. Turning it on or off will require a reboot.
Short of that, you can only obtain the information in kernel mode, and that will require a device driver.
|
|
|
|
|
Do you mean the context menu of a file by this "file status(ie. open, close, edit)", or do you mean if a file can be accessed, opened for reading/writing, etc.? You can do that by calling _open[^]
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Just i want to get current status of the file. ie.
1) It is opend
2) It is Closed
3) It is modified
Thanx
|
|
|
|
|
You need to be more clear.
1) A file might be opened in the sense that there are handles of that file opened by one or more processes.
2) I don't know what you mean by "closed", is it that no process has opened the file currently?
3) A file has always been modified somewhere in the past, it might be a minute ago or a month ago or 10 years ago. That's how you create a file, you create it empty and then modify it. Do you mean that you want to get the date of last modification? What do you mean by "it is modified"?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Accessing File Status (MFC)
Also, you can try CFile::GetStatus
CFile theFile;
char* szFileName = "X:\\TEXT.TXT";
BOOL bOpenOK;
CFileStatus status;
if( CFile::GetStatus( szFileName, status ) ) bOpenOK = theFile.Open( szFileName, CFile::modeWrite );
else bOpenOK = theFile.Open( szFileName, CFile::modeCreate | CFile::modeWrite );
http://msdn.microsoft.com/en-us/library/e3z63bza(VS.80).aspx[^]
.
|
|
|
|