|
Here is how I have done it in an MFC application:
In the .rc2 file, include the file you want to extract
ResourceName ResourceType "ResourceFilename"
To extract it:
ExtractFile("ResourceName", "ResourceType", pathname);
bool ExtractFile(const CString& resourceID, const CString& resourceType, const CString& filename)
{
bool bOK = true;
HANDLE hRes = ::LoadResource(hInstance, ::FindResource(hInstance, resourceID, resourceType));
if (hRes != INVALID_HANDLE_VALUE)
{
DWORD sizeOfResource = ::SizeofResource(hInstance, ::FindResource(hInstance, resourceID, resourceType));
char *lpRes = (char*)::LockResource(hRes);
CFile file;
if (file.Open(filename, CFile::modeCreate | CFile::modeWrite))
{
file.WriteHuge(lpRes, sizeOfResource);
file.Close();
}
else
{
bOK = false;
}
::UnlockResource(hRes);
::FreeResource(hRes);
}
return bOK;
}
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
See if this article is of any help.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I'm not too saavy in Visual C++ programming as most of my C/CPP has been in embedded platforms.
I'm working on a host application which is a VC++ window. Essentially, for this one particular window I want it to stay on top all the time. I have added some code that was given to me by someone who has done it in another application before, but it does not seem to be working in mine. Can anyone help?
Here is what I have:
<code>
CWnd appWnd;
CWnd *pAppWnd;
pAppWnd = & appWnd;
pAppWnd = AfxGetMainWnd();
if (NULL != pAppWnd)
{
HWND appHandle;
appHandle = pAppWnd->GetSafeHwnd();
if (NULL != appHandle)
{
targetObj.m_pAppWnd = pAppWnd;
}
}
targetObj.m_bWindowStayOnTop = TRUE;
</code>
targetObj is another class which is essentially being called by this (no "gui" elements in that class) and in that class, inside of a loop that he is in, I have this part:
<code>
if (TRUE == this->m_bWindowStayOnTop)
{
BOOL bReturn = FALSE;
if (NULL != this->m_pAppWnd)
{
bReturn = this->m_pAppWnd->SetForegroundWindow();
}
}
</code>
It seems that the return from SetForegroundWindow() is 0 which means it is failing. But I don't know why! Any ideas?
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
::SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
If that works, I am a superman, seeing as I've done nothing like this for years. It's damn close though. setwindowpos takes as it's first parameter a value that allows you to make a window move to the top or bottom, or make it topmost (i.e. top and stay there ). You pass whatever you like for the position and size, and use flags to make them irrelevant.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You are my superman!
It wasn't exactly right, but (hang on..moving window now in my way)....it was damn close!
Appreciated!
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
KingTermite wrote:
hang on..moving window now in my way)....
LOL - brilliant.
And you're welcome
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Does anyone know of a source for info on how to set up the VC6 environment to work with the free VC7.1 compiler that Microsoft has made available?
I could probably puzzle it out for myself, but step-by-step directions would be so much nicer.
Thx
|
|
|
|
|
I haven't tried this, but my first thought was go to Tools->Options->Directories->Executable files. The compiler/linker/etc are in %VCDIR%\vc98\bin , so change that line to wherever the VC 7 tools are.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
Thanks, Michael, that's a start.
|
|
|
|
|
|
Compiler works - after I made a bunch of changes to the code (all STL-related) - but now I can't link.
|
|
|
|
|
Is using the StreamIn function the only way to add text to a rich edit control programmatically? Thanks.
- Aaron
|
|
|
|
|
SetWindowText() comes to mind.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The problem with that is I'm pretty sure it would remove the text that was already in the control. I'm looking for a way to be able to append to any text that is already in the control.
- Aaron
|
|
|
|
|
monrobot13 wrote:
I'm looking for a way to be able to append to any text that is already in the control.
You'll want to use ReplaceSel() then.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
That's exactly what I'm looking for. Thanks very much.
- Aaron
|
|
|
|
|
i have a serious problem... i need to create something that is able to edit midi files (it's obligatory school project) but i'm a newbie in c++ coding and despite browsing the whole internet :] i've only found some obsolete or complicated classes. i hope there are some people who can help me any links, hints or good ideas are welcome... plizzzz, i'm runnig out of time :/
|
|
|
|
|
|
|
Posts like these never make sense to me. A MIDI editor is not something that is assigned to a beginning C++ student. I'm not sure if the blame falls on the instructor for assigning such a "heavy" task, or the student for not paying attention the first 3/4 of the class. The fact that you (immediately) started looking on the Internet for the answer suggests the latter.
In any case, what specific part of the problem are you having difficulty with? "The whole thing" is not an answer. One of the obvious things to know would be the format of a MIDI file. There are up to five links here discussing the file format.
How about file I/O? For that, I would lean towards a CFile object and its members.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I use some messageBox in my program.
And When I click OK button on a messagebox then the program closes completly.
in other programs messageboxes don't do this and works without any problem but in one program that is important for me does.
I used direct windowsXP messageBoxes via p/invoke methot.
But the result has not changed.
exactly I could't understand the spring of the problem
|
|
|
|
|
You'll need to post some code or give a better description of your problem. However, it sounds like you have no message loop (or implemented it incorrectly).
Jeremy Falcon
|
|
|
|
|
deniz79s wrote:
I used direct windowsXP messageBoxes via p/invoke methot.
What is a "p/invoke methot?"
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i have a program done using the doc/view architecture. i want to change the font of whatever text i display in the view but am unable to figure out how to do so and in which member function of CView such as OnDraw, OnUpdate, etc?
|
|
|
|
|
Hi,
In the OnDraw function you can select a new font into the DC and do all your drawing(text) and it will be in that font.
CTestView::OnDraw(CDC *pDC)
{
CFont NewFont;
NewFont.Create(Specify Parameters);
CFont *pOldFont = pDC->SelectObject(&NewFont);
// Draw your text
// Select old font back
pDC->SelectObject(pOldFont);
}
Hope it helps
Vikash Parida
|
|
|
|