|
Hi Mathew,
I'm reasonably sure CArchive is only a streaming format, which means you can't selectively write to a part of the file. ie. In your example the count of objects at the start. Appending to an existing archive should work ok.
I use a similar technique to the one you describe to manage an array of Style Sheets in ED (see sig). When I want to save the style sheets array I recreate the file from scratch as follows:
if ( bStat = SSfile.Open( m_SSFileName, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive, &FileException ) )
The count is written at the start of the file.
If you want to be able to append to the file and modify a header record I don't think CArchive is appropriate.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
|
Just a quickie,
I have one member function
HWND CAutoRestartDlg::GetProcessWnd()<br />
{<br />
... <br />
EnumWindows((WNDENUMPROC)CAutoRestartDlg::GetWndProc,(LPARAM)0);<br />
....<br />
}
and also my callback function:
BOOL CALLBACK CAutoRestartDlg::GetWndProc(HWND hwnd, LPARAM lparam)<br />
{<br />
...<br />
}
When I try to compile, I get error C2440: 'type cast' : cannot convert from '' to 'int (__stdcall *)(struct HWND__ *,long)'
What am I doing wrong? Would appreciate some help. Sorry if it sounds a bit thick but I am feeling very thick at the moment.
Many thanks
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
|
Thanks Joaquin,
I can't see for looking some days. I appreciate your help!!
Cheerio for now and thanks once again.
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Make sure GetWndProc is declared as a static function in your CAutoRestartDlg class. Most any time you define a Win32 API callback function inside a class you need to make the function static. This is because the Win32 API is written in C and C can't handle C++ classes and their polymorphic abilities. The API needs to know at exactly what position in memory your function resides so that it can call it. Polymorphism allows run-time determination of function addresses. Static functions -and static member variables, too- are allocated once when your app begins and never move for the duration of your app's existence. Only one copy of a static function exists in memory for the entire class; regardless of how many instances of the class you create.
Static functions are basically identical in nature to any old C-style function you'd create outside of your class. The only difference is that they're located in your classes' namespace, so you can keep things neat and know where to look for the code. That's really the only reason why they're even allowed in a class; you don't get any object-oriented features with static functions.
One additional note to preempt further frustration... static functions inside C++ classes cannot directly access anything inside the class except other static member variables or static functions. IE if you had an integer member variable named m_iMyVar, you could not read it nor set it unless it were also declared as being static. This is because only one copy of the function for the entire class exists; it would not know which object instance to use when setting the member variable or calling the other function. If you want to actually use something inside your CAutoRestartDlg class you'll have to use the LPARAM portion of your call to EnumWindows() and pass along a pointer to the class or a struct which contains a pointer. I can whip up some code if you'd like to see an example of this.
Sorry for the over-explanation if you knew this stuff already I guessed from your code that you probably already tried various casts.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Hey Ty,
That's excellent. A big THANKS! Really, more explanation is better than less, for me anyway. I got really fed up late last night wondering I kept getting the error message and not being able to figure it out. It's just that the explanation of the error does not give any indication that the function would have to be declared static. Hence my frustration!
Thanks once again! Totally appreciated.
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Okay, now you have managed level 1, let's go up to level 2
Using only static member functions (also called class functions) or ordinary C functions as callbacks is boring and odd. But you can use adapters to "translate" a call to a static function seamless into a call to a real member function.
If you are interested in more technical details about the "callback has to be static" issue and a complete solution for it you may want to check out my article Use member functions for C-style callbacks and threads - a general solution.
However, you don't have to read the whole article, you could also just use the provided adapters. It allows you to write code as simple as the following:
#include "stdafx.h"
#include "win_adapter.h"
struct DATA { int foo; double bar; };
class Test
{
public:
virtual BOOL WindowLister( HWND hWnd, const DATA& data )
{
printf(" Window: %p\n", hWnd );
return true;
}
void DoStuff()
{
DATA someData;
win::EnumWindows( this, &Test::WindowLister, someData );
}
};
Programming is fun!
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
What is the best way to smooth window movement on static controls such as picture controls in msvc++ and mfc.
i currently use,
hStruct.HSliderCover = iLoadBitmapFromFile( "graphics/slider_cover.bmp", 0 );
m_picSliderCover.SetBitmap( hStruct.HSliderCover );
m_picSliderCover.SetWindowPos( &wndBottom, 0, 0, 553, 62, SWP_NOMOVE );
CRect rect;
m_picSliderCover.GetWindowRect(rect);
SetTimer( SliderTimer, 1, NULL );
//slider timer
if( nIDEvent == SliderTimer )
{
rect.left++;
m_picSliderCover.SetWindowPos( &wndBottom, rect.left, 420, 0, 0, SWP_NOSIZE );
}
any help would be great.
|
|
|
|
|
There are most likely lots of ways to do this, including the one you're using. My two suggestions are:
- Use a borderless popup window displaying the bitmap, move it - should be accelerated on any not-completely-worthless OS+video card. Or,
- Save an image of the portions you are covering to memory, and then use a separate in-memory bitmap to draw part of it covered by your slider each timer interval; then draw the complete image to the screen in one go.
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
On the users machine, my install program will register the VB com dll automatically. Question is where should I put my VB Com dll? Does it matter? Or will the app go to the registry and locate it itself? The method I'm using to hook the dll has code like :
_ClRemoteCall p;
p.CreateDispatch("DllwithForm.Class1");
and I go through the class wizard .
Thanks,
ns
|
|
|
|
|
If the DLL is specific to your progam (as I guess it is), then it is best to copy it to the target directory where all other stuff belonging to the app inhabits. The registration process takes note of the path where the DLL is, so you have complete freedom to choose its location.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Good to know for sure
Thanks,
ns
|
|
|
|
|
Hi
I'm trying to paste bitmap from program resources into a clipboard:
#ifdef UNIETSIOFFICE_EXPORTS
#define UNIETSI_API __declspec(dllexport)
#else
#define UNIETSI_API __declspec(dllimport)
#endif
int UNIETSI_API WINAPI uniETSIOfficePasteIcon(int nIconId)
{
CBitmap Bitmap;
Bitmap.LoadBitmap( nIconId );
OpenClipboard( 0 );
SetClipboardData( CF_BITMAP, Bitmap );
CloseClipboard();
}
This function is in mfcdll(mfc is linked statically) and everything works perfect in Win2000 (in which I have made my dll) but when I have tried this in Win98 nothing appears in clipboard(dll works, my function executes, all functions used in this code seems to work - return code !=0 - but nothing appears in clipboard). I don't know what is wrong.
Greetings
Mariusz Popiolek
|
|
|
|
|
Is it an icon that you're trying to load? If so, try loading a bitmap instead and see what happens. If is the icon bit that is failing, you might want to use LoadImage instead.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm trying to paste bitmap, but I will try to use LoadImage, maybe it will solve the problem (I hope).
Greetings
|
|
|
|
|
Try adding EmptyClipboard() call after OpenClipboard.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
I have an app that has uses the Webbrowser ActiveX object. My problem is that the web site that the Web Browser should show needs to be current and not taken from the history, temp file, or cashe. What I want to know is how to delete or prevent the history, temp internet files, and or cashe from displaying old material, instead it should get the data from the Web Server everytime(Plus be able to detect if it is offline or not).
If anyone can put point me to the river which contains this information, or show me how it is done, I shall be very gratefull. Thanks in advance Shell Gurus and Friends for your advice and guidance!
|
|
|
|
|
First of all, a way to make sure the web page is always up-to-date, is to use the expires meta-tag with 0 as value :
<META HTTP-EQUIV="expires" CONTENT="0">
Now it's easy if you generate yourself the served web pages.
If you don't, you'll need to use the web browser control API IHTMLMetaElement to update the current web page.
More info on syntax here[^].
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I have a better answer for you. Hope you like it.
See here[^].
Yes, to do what you need you just need to set the IE settings.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Hi everyone,
I was searching the net for some programming resources and I stumbled upon this site. I'm looking to eventually get a posistion in the game developing business, but firstly I need to gain experience in programming. I'm 19, and going to college next fall, and I was wondering if maybe you guys could help me out. What is the ideal degree to have for a job in the programming field? I'm very computer literate, but have no knowledge of programming. The most well known language to me, or atleast most heard of, is C++. Would it be wise to perhaps buy Visual C++ and start working with it on my own? It would seem advantageous to me, if I know a bit of computer programming even before I went to college for my degree. Lastly, are there different programs to write C++? Or is it just Microsoft that makes the product?
Thanks,
Brandon
|
|
|
|
|
What is the ideal degree to have for a job in the programming field?
Computer Science, I guess. At least in my country, electrical engineers do quite a bit of programming work, too. If you're good at programming, I don't think the degree you take will make any significative difference when it comes to finding a job in the game industry (but definitely having a degree is better than not having it).
Would it be wise to perhaps buy Visual C++ and start working with it on my own?
Very wise.
Lastly, are there different programs to write C++?
Well, for Windows platform, VC++ is almost the only actual choice. There are other products, but they don't receive as much attention as VC++ does, by far.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The standard in the gaming industry is still C++ at this point. There are several options to programming out there as far as languages and I have heard of some games programming done in every language that exists. I would recommend Computer Science, although Electrical Engineers are good as well. However I think in Electrical Engineering you may learn more fun stuff (I am an electrical Engineer) you lose some of the theory of programming that may give you an edge over other candiates if all you want to do is software. However you may want to look at a software engineer program if one is available as that would merge more of the two disciplines.
In my honest opinion for what you hope to accomplish studying C++ would be your best choice. Getting used to the Microsoft Visual C++ will get you closet to most gaming environments that are out there, but once again it is not the only flavor of c++ on the market. Linux has gcc. There is borland c++. Each of these will allow you to learn the language and get you in to programming and give you experience.
Another approach for entering the gaming industry and one that I have been exploring is to download the tools for modifying a current game. These modifications often have a script language which is very similiar to C/C++. These are good tools to let you see what is ahead of you, however they may be a little confusing to start with. Don't worry too much about that, but they are good demos.
Lastly, coding or programming to me is a skill that translate well accross boundaries more readily than most. I have worked in Visual C++ for many years now, but after I was laid off and started my new job, I was forced to support Visual Basic code for a while. The reason I say this is that even studying visual basic will help you learn to code and understand object oriented programming. The syntax however will be different, but if you learn to understand outside the syntax and understand the concepts, any language will work for you.
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
SanShou wrote:
However I think in Electrical Engineering you may learn more fun stuff (I am an electrical Engineer)
You're saying that doing all those circuits analyses and Fourier transforms are fun! It's *because* of all my analog circuits that I'm in software development! bleh. That was some evil stuff.
(end rant)
|
|
|
|
|
Since you're interested in game development, search the microsoft website for directX. Get the sdk and documentation. The programming language would be C/C++, but that's not very important. It's something you learn as you experiment with the technology you're interested in, in this case gaming. I hope you're a dedicated geek , computer science is not for career minded people. You have to love it to succeed in it. Most aspects of it can be very fustrating, only a passion can get you to where you want to be. Especially something like game programming.
|
|
|
|
|