|
Does anyone have a code snippet (or can describe) how to load contents of a file into an object that exposes the interface IStream? The idea is I want to be able to pass an IStream which can be used to read the contents of this file. There does not need to be a direct link between the interface and the file - I need to load the file's contents into the object and access the aforementioned contents using IStream..
TIA!!
|
|
|
|
|
One implementation looks like :
CreateFile() and ReadFile() to open and read the file contents. Then create a new IStream(CreateStreamOnHGlobal()) and then
pStm->Write();//write file contents
I haven't checked this out. but theoritically this ought to work. These is also the new SHStreamOnFile() function that seems to do what we want.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
Thanks, Amit.
That, in fact, does work. I had discovered it a couple of weeks ago (I forgot to follow-up on my question). Once you've got a memory buffer and a corresponding HGLOBAL, you can use CreateStreamOnHGlobal to generate an instance of a stream object with an IStream interface.
Thanks!
|
|
|
|
|
Yes, I tried it too. Now let us suppose we were to write something like StreamFromFile([in] LPCTSTR szFile,[out,retval]IStream *ppStream). I can only see a related MAPI utility function and an shlwapi 5.0+ function SHStreamFromFile(). The implementation I guess is no longer a mystery.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
hi,
how do i change the titlebar text of a sdi program? i want the titlebar to display "My program", not "My program - Untitled".. is there a way to make the windows not displya "- Untitled"? i tried modifying idr_mainframe, but that didn't work.. thanx in advance..
|
|
|
|
|
|
thx for the help, once again.. mike.
|
|
|
|
|
I know this sounds crazy but I'd like to build an application that will allow we to modify other applications' icons. I have an application that generates other small exe files and I want to allow users to select or paste an icon into my configuration app for them. Is there an API for this ? Any ideas about how to do this ? I want to do it in VC++
Thanks,
Matt
|
|
|
|
|
take a look at the UpdateResource() function
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
I'm trying to get the source code of a web page.
It usually works fine, but on some web pages, like www.altavista.com or www.aol.co.uk I get something else. it looks like the server is sending something to 3rd party sites, and althoguh I can see in the browser the correct page, my code gets another page, completly different.
I use the WebBrowser2->get_Document
then IHTMLDocument2->Get_body and then ->Get_outterHtml
I read the page when DISPID_DOCUMENTCOMPLETE is fired.
Any ideas how can I get the real page from this sites and not the redirected one ?
(remark - on explorer 5.0 I got the correct page I think..., it looks like explorer 6.0 change something in this matter).
Regrads,
Dani.
|
|
|
|
|
Try using sockets. If you use sockets the same way as internet explore does let me explain how you could telnet to a website and thus retrive the HTML data as "internet explorer" does. You would telnet to a website and then send the text string of "GET index.html HTTP/1.0" Without quotes. Basically that is what we call a header that is sent to a website. So if you were to want to use this to make an app to get to a website simply connect to the website on port 80 and send the string get index.html HTTP/1.0 or HTTP/1.1 depending on server. Using this is how websource is retrived.
- LiquidKnight
|
|
|
|
|
You are getting the code that is received by IE after it formats it. If you want to get the unformatted code Look into the IPersistStream interface. The code will look something like this:
HRESULT GetDocumentContent(CComBSTR &bstrHTMLText)
{
bstrHTMLText.Empty();
CComPtr<IDispatch> pDisp;
HRESULT hr = m_spWebBrowser2->get_Document(&pDisp);
if (FAILED(hr))
{
return hr;
}
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML = pDisp;
if (spHTML)
{
CHAR *szData = NULL;
OLECHAR *htmlText = NULL;
try
{
CComQIPtr<IPersistStreamInit, &IID_IPersistStreamInit> spData = spHTML;
CComPtr<IStream> spStream;
::CreateStreamOnHGlobal(NULL, TRUE, &spStream);
spData->Save(spStream ,FALSE);
STATSTG stat;
spStream->Stat(&stat, STATFLAG_NONAME);
szData = new CHAR[stat.cbSize.LowPart];
ULONG length;
LARGE_INTEGER pos;
pos.QuadPart = (__int64)0;
spStream->Seek(pos, STREAM_SEEK_SET, NULL);
spStream->Read(szData, stat.cbSize.LowPart, &length);
htmlText = new OLECHAR[length];
::MultiByteToWideChar(CP_ACP, 0, szData, length, htmlText, length);
bstrHTMLText = htmlText;
}
catch (...)
{
}
delete[] htmlText;
delete[] szData;
}
else
{
}
return S_OK;
}
This function is taken from a class that I wrote, so you may need to rework it a little.,
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
anyone know of any samples for detecting multiple displays, and more so, which display the app is on?
any help or pointers in the right direction are appreciated
shotgun
|
|
|
|
|
GetSystemMetrics(SM_CMONITORS) will give you the # of monitors installed. Use MonitorFromRect() to tell which monitor a window is on (or which monitor it is mostly in, if it spans more than one)
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi.
I am an experienced 'C' programmer trying to venture into the MSVC++ programming world.
As my first serious graphical C++ project I am trying to recreate the old Tetris program.
However, I am having some difficulty trying to determine where my main processing loop should live and how it should initiate drawing a shape.
I have no problem managing and randomly selecting shape imagelist orientations for display, the problem is what type of application is most suited to this type of program and where should my control loop live.
I would very much appreciate any guidance that you might have.
Thanks in advance.
James.
|
|
|
|
|
Think of it as this. You have to update the window every "frame" CheckForUserInput->Update Display By doing this you will ultimately beable to get input as well as display objects its kinda like with rendering Im not sure exactly how your doing it but if your using OpenGL Or directx just put it "before" or after the rendering process.
- LiquidKnight
|
|
|
|
|
Check out http://nehe.gamedev.net[^]. This guy uses VC++ 6.0 to write OpenGL programs and has a great tutorial.
Brad Jennings
"if the golden arches shut shop, where else are the VB people going to get work." - Colin Davies
|
|
|
|
|
Hmm, just went to http://nehe.gamedev.net and none of the tutorial links seem to work. He does still have them available for download though (a little farther down the page).
Brad Jennings
"if the golden arches shut shop, where else are the VB people going to get work." - Colin Davies
|
|
|
|
|
Thanks for the two suggestions and the link.
I think that I might have over stated the 'seriousness' of my attempts at a graphics program.
My approach is very simple.
I have designed some image lists comprising a number of bitmaps to represent the orientation of each shape.
I simply randomly select an imagelist and bitmap and use this to draw to the window view.
Since the format of the Tetris program is to simply draw the image advancing/rotating/moving side to side it does not involve any complex graphics manipulation.
I simply use BitBlt.
My problem is the type of VC++ application I should define so that I can have a control loop somewhere that generates these random shapes and dispatches them to be drawn.
I defined a straight forward SDI application and tried to use it as my base, but I do not know where my control loop should be placed.
Is this the right kind of application for this type of program ? or do I need another type WIN32 etc ?
As I say, my problem is not realy knowing the windows/MFC generated environment.
Any advice would be very welcome.
|
|
|
|
|
The trick is for a game processing loop, is that you want to update your graphics after all of the input has been processed.
In MFC, the processing loop is hidden from you, but you could always override the PretranslateMessage function, but that could get a little messy. Other than that, I am not an MFC guru so I do not know the simple way to change the message processing loop in MFC.
If you go for a plain Win32 implementation, that would be a lot easier. Your message pump should look something like this:
while (TRUE)
{
if (PeekMessage( &m_msg, NULL, 0, 0, PM_REMOVE))
{
if (WM_QUIT == m_msg.message)
{
break;
}
if(!PreTranslateMessage(&m_msg))
{
::TranslateMessage(&m_msg);
::DispatchMessage(&m_msg);
}
}
else
{
OnUpdateFrame();
}
You should use PeekMessage because GetMessage blocks until a message becomes available. There are other things that I omitted from this loop that will help your idle processing and when the game is paused.
If you are adventurous, and understand C++ templates, you may want to checkout WTL. I wrote a full version of Tetris in DirectX for this, and there is a base window that you could use to start your version.
I also wrote a class that is a modified gameloop for WTL, so you would not have to mess with this. This code can be found here: WTL GameLoop[^], and my Tetris game can be found here: Tetris[^]
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Who has C/C++ experience about 3-4 years with experience with: Win32, MFC, Javascript, and Visual basic inlcuding, HTML, CSS, Java, Open GL, some Perl, some PHP, some assemebly, some directx type api stuff. What would be the adverage yearly income on a starting position of someone with those following skills. Thats with only some college education no degrees as of yet.
- LiquidKnight
|
|
|
|
|
Um maybe 20k to 25k if you're lucky
|
|
|
|
|
Even with a very high level of C++ experience?
- LiquidKnight
|
|
|
|
|
Benny is right on. If your 3-4 years experience is work experience (and not "playing" at home), maybe a bit more. You don't start into the serious money until you have several projects under your belt and can demonstrate all of the skills not directly related to writing code (like doing software requirements/design docs, working in a team environment, generating formal test procedures, user documentation and follow up support including program updates and associated paper work). This is especially true for government contracts - a lot more time is spent on the paper work than actual coding. When I stated out (25 yrs ago), I was making about 14K a year. In six years, that figure just about tripled. This was in OS & compiler design and not application programming.
Steve
|
|
|
|
|
It depends on the kind of experience.
Somebody who knows STL inside out and every nuance of the C++ Standard might be good but if he doesn't have experience of building MFC GUI apps talking to a database then his experience doesn't have much commercial value to my company.
Michael
The avalanche has started, it's too late for the pebbles to vote.
|
|
|
|