|
how can I load a bitmap from file and display it inside (let's say) a static control?
thank you
|
|
|
|
|
|
A. You can go to Resource Editor and add bitmap to your resources. Add static picture control to your dialog, make it type bitmap and set the ID of the bitmap you loaded as resource for this control. This is done before you compile.
B. Use an imaging library. I like FreeImage. There are others: CxImage, DevIL etc etc. So loading a bitmap depends on the library you use. There's some code
http://freeimage.sourceforge.net/developers.html#faq. Once you load the image, override the class for the user control you're using and implement OnPaint() function to draw the bitmap you loaded.
This should get you started.
|
|
|
|
|
i want to count print outs printed by printer is any way to do this plz suggest me.
i am making cyber cafe managing software i need to count print out in my program
|
|
|
|
|
How can I programatically find out if MS Excel is installed on a PC and where it resides?
Thanx!!
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
I would reccomend going through the Registry. Read HKEY_CLASSES_ROOT\.xls and see what the associated program name is. If this key doesn't exist you know right away that Excel is probably not installed. Next take the value read from the default value (usually something like "Excel.Sheet.8") and look for it in the registry with the command path appended:
HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command
The default value of that key will tell you the location of Excel. You will have to parse it up a bit though. Hope that helps.
|
|
|
|
|
HKLM/Software/Microsoft/Office/<Version>/Common/FilesPaths
|
|
|
|
|
Thx!!
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Hey All,
I have a property page with an embedded CFrameWnd that is the child of the page. I can add CToolbars and a CStatusbar with absolutely no problems, and I am using a CRichEditCtrl for the view. But I am unable to add a menu to the frame. Calling SetMenu() fails and GetLastError() returns 0x59c ==> Child windows can not have menus.
Does anyone know of a way that I can add a menu to a child CFrameWnd, in such a way that the default toolbars still work? I tried Yao Zhifeng's CMenuBarXP class[^]. While it did put a menu in place, it did not cooperate with the layout mechanism of the frame and would simply draw itself overtop the toolbar and/or the edit control.
Basicly what I am after is to embed a complete SDI frame window into a CPropertyPage. Any links or hints would be appreciated.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Off of the top of my head, there would be two things that I would try:
1: "Fake" it, by creating a toolbar that uses text for buttons and then activate menus in-place when the buttons are pressed, kinda how some dockable menu systems work
2: Embed the menu in a rebar, and place the rebar in the window.
Hey - can you add a menu to a CDialogBar? If so, you can dock it to the top of the frame.)
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks for the suggestions James. I will look into the rebar and dialogbar options. The first option of "faking" it does not appeal to me at the moment, but may end up being the choice of last resort.
I was actually hoping for a link to an article written by someone who had already done this and had figured everything out.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
i was surfing the whole noon just looking on how to create a shared folder over network with permission. i also couldn't found any example in MSDN. at last i found some code snippets on some forum.. anyone could give some code snippets? thanks in advanced.
SECURITY_INFORMATION SecurityInformation;
SecurityInformation = OWNER_SECURITY_INFORMATION;
SECURITY_DESCRIPTOR SecurityDescriptor;
ACL Acl;
SID Sid;
DWORD dwAclAllowed;
dwAclAllowed = sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(&Sid);
InitializeAcl(&Acl, dwAclAllowed, ACL_REVISION);
InitializeSecurityDescriptor(&SecurityDescriptor, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorOwner(&SecurityDescriptor, &Sid, TRUE);
SetSecurityDescriptorGroup(&SecurityDescriptor, &Sid, TRUE);
SetSecurityDescriptorDacl(&SecurityDescriptor, TRUE, &Acl, TRUE);
SetSecurityDescriptorSacl(&SecurityDescriptor, TRUE, &Acl, TRUE);
SetFileSecurity(strOCRDownloadFontLibPath, SecurityInformation, &SecurityDescriptor);
from,
-= aLbert =-
|
|
|
|
|
This may be a general doubt but I do need clarification .
I have declared a userdefined class object m_pElement as a member of CMainFrame.
I want to release its memory in the destructor in the foll.manner.
CMainFrame::~CMainFrame()
{
if (m_pElement)
delete m_Element;
}
But if I had not declared memory for pElement using 'new' the above destruction leads to exception.
How to check for allocated memory and then release the memory for pElement.
laiju
|
|
|
|
|
In the class constructor of CMainFrame, set pointer to NULL:
CMainFrame::CMainFrame()<br />
{<br />
m_pElement = NULL;<br />
}
Like that, in your destructor, if the pointer is NULL, it won't be destroyed.
|
|
|
|
|
Set m_pElement to NULL in your constructor. Then, the if statement will actually work and the delete will not be executed. And even if it is, it's not a problem to delete a pointer to NULL. In your case however, m_pElement can point to 0x0ccccc (arbitrary) and you're trying to delete it which is not legal.
|
|
|
|
|
i am working in MFC VC++ and need to read a specfic line, and only that line from a text file. Is there a readline() function or something like that?
thanks
|
|
|
|
|
is std::ifstream::getline() useful ?
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
There is _fgetts(...) function.
Are you looking for something MFC-specific, like CStdioFile::ReadString(...) ...? Or something that uses native Win32 HANDLE s?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I'm not sure I'm doing the right thing.
I have a CStatic in a dialog ( with the associated variable in the dialog class ), and I want to change the "weight" of the font of the CStatic, make it bold or normal depending on a state.
Can I do something like :
CFont* font = m_MaxStatic.GetFont();
LOGFONT logFont;
font->GetLogFont( &logFont );
logFont.lfWeight = FW_BOLD;
CFont newFont;
newFont.CreateFontIndirect( &logFont );
m_MaxStatic.SetFont(&newFont);
when I do the above, the font seems ok, it appears bold, but if the dialogs ( or the control ) gets invalidated, the font (size) is different.
Do I need to make the 2 different fonts (normal and bold) class members ( of either the dialog or a derived CStatic class ) ? or is there a better way to dinamically change the font of a control ?
Should there be a functional difference between small fonts vs. large fonts.
Thanks a lot.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
CFont newFont;
You are creating the font correctly. But since it is local to the function, it goes out of scope when the function exits. This means that the font the control is trying to use has been destroyed. So the next time it tries to draw, it no longer has a valid font.
Make the CFont object a member of the class. That should do it for you.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Yeah, thanks, It figures ...
(ranting)
it's kind of weird that I have a CWnd object with the SetFont() method and I need to keep a local copy of the font ... why can't it copy the font instead of keeping a pointer to it.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
It allows only a single instance of the same font to be used with multiple controls, and you (the developer) maintain its lifetime, so there is no additional allocate-copy-deallocate overhead.
I would not want to set the font for 20 controls on a non-modal dialog, then open a few copies of that dialog, and have MFC have a bunch of identical copies of a font being managed.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
|
Thanks for the faq link ...
I will hide under a rock ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I've tried to implement the MATLAB C++ Math Library using Riazi's article posted 28 May 2003. I get a link error 'cannot find the file "MSVCIRT.LIB". I've tried the recommended fix (/nodefaultlib "MVSCRT.LIB" and (/nodefaultlib "MVSCIRT.LIB") which yields more undefined symbols. I've also tried selecting multithreading and still get the error. Any suggestions would be appreciated.
Ron
|
|
|
|