|
I have a configuration file that gets really big plus the memory needed is very high to load, use, and save file.
I know i can open a file w/out losing the data I had before when opening a file using the modeCreate bit on.
then I can overwrite data using seek() and the Write() or WriteString() for example.. (note I use C/C++(//) comments even on the lines of my file.)
//Load State
This is a very boring file.
//Load State
//Save State// file size not changed
This is *******boring file.]// Overwritten "a very " w/ "*******"
//Save State
Now I want to use overwriting and inserting of data in my configuration file.
Here is what I tied...
//Load State
....
[section ref]
48
[section ref]
23
....
//Load State
//Save State// file size not changed
....
[section ref]
23458ection ref]// Overwritten 48 but also Overwritten '\n' and "se" of the next line
16457
....
//Save State
So what I need is a memory saving function to extend the file x bytes and move all the following data down x bytes.
Here is what I need...
//Load State
....
[section ref]
48
[section ref]
23
....
//Load State
//Save State// file size will hope to be changed
....
[section ref]
23458// Overwritten 48 and added 3 bytes and pushed the down 3 bytes and extended the file 3 bytes
[section ref]
16457
....
//Save State
Thank you for your time.
I hope everyone can understand what I am getting at.
|
|
|
|
|
1) Open the existing file.
2) Open a new file.
3) Read the data to the point of insertion, writing this to the new file.
4) Write the new data to the new file.
5) Read the rest of the data to the end of the file, writing this to the new file.
6) Close old file.
7) Close new file.
8) Delete old file.
9) Rename new file to old file.
Hope that helps.
Wayne
|
|
|
|
|
I know this would work but the configuration file can get very big is save alot I am looking at file access proformance at this time.
|
|
|
|
|
I need to add one char after standard clock window in tray. I have it's HWND.
I also understand I have to subclass this window but can anyone give me a hint how exactly?
Source code very welcome!
Thanx in advance,
Julia
|
|
|
|
|
<<< In the name of GOD >>>
Hi all.
I deleted the menu item from my main menu,
Now, i want to update the menu, because the menu not compeletly clear of my menu !!!
HMENU hMenu = ::GetMenu(m_hWnd);
::DeleteMenu(hMenu, 4, MF_BYPOSITION);
Thanks for reply ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I found my answer ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
How can i change the width of a tab in the property page?
Works it automatically via modifystyle or have i to do it manualy via set windowpos or similar and where can i do this?
Does anyone know?
|
|
|
|
|
Is it possible to get info of which function throws an exception? I want to know if CFile::Close() throws an exception in the CATCH block.
CATCH( CFileException, e )
{
// Does something like this exist?
if( e->ThrowingFunc() == Close )
{
//some code
}
}
Thanks
Daniel
|
|
|
|
|
Just put the CFile::Close() method into it's own try/catch block and that way you will know which function has thrown the exception. In terms of wether an exception 'knows' what function it has been thrown from, I don't believe that this exists.
Chris
|
|
|
|
|
I want the application window to have a gray background upon start up.. does anyone know how to do it?
|
|
|
|
|
Two ways. 1 - When you register your window class, create a gray brush and pass that as the background brush in the WNDCLASS(EX) struct. 2 - Handle the WM_ERASEBKGND message and paint the gray background when that message is sent to you.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
In your window class that is registered set the brush to the stock brush index of COLOR_BTNFACE if you don't think the user will play around with their windows color scheme else pass in the handle to the GRAY_BRUSH from GetStockObject.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
<<< In the name of GOD >>>
Hi all.
How can i save RichEdit data to file ?
I wrote it, but it have errors ...
static DOWORD CALLBACK MyStream(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile *pFile = (CFile*) dwCookie;
pFile->Write(pbBuff, cb);
*pcb = cb;
return 0;
}
void CTestDlg::OnOK()
{
EDITSTREAM es;
CFile file("c:\\test.txt", modeCreate);
es.dwCooikie = (DWORD) &file;
es.pfnCallback = MyStream;
m_RichEdit.StreamOut(SF_RTF, es);
}
If possible write example about saving richedit data to file.
Thanks for reply.
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I'm trying to convert a series of 3D points (XYZ) to a 2D (XY) surface.
In my application a series of lines run along the axes (think of pipes fitted together with elbows, tees, and crosses), they are 90 deg to each other.
I simply do the following to map my XYZ points to the YZ plane:
xp = (z + x * COS_45);
yp = (y + x * SIN_45);
This is not quite right. When drawn on a metafile, lines in the Z direction run Parallel to bottom edge, they should actually be at 30 deg. I can see that I need to get an x and y added value from the z-component, however I haven't had much luck.
A simple set of points:
(0,0,0)
(20,0,0)
(20,20,0)
(20,20,20)
(40,20,20)
Does anyone have the appropriate transformation/formula that I should use? Or good place to look? (I was trying to avoid matrices and doing some type of world to eye to screen transform - it seems it should be easier, since all my lines are at 90's)
Thanks
Mike
|
|
|
|
|
I have a 2 Column CListCtrl and I need to edit the text on the CListCtrl by DoubleClicking on the cell(in second column)
Would some one give a hint on how to do this.
Thanks
Iraivan
|
|
|
|
|
I develop a dialog box when I use the monitor resolution to 1024x760. However, I found that if i change the resolution to 640x480, the dialog box will be too big. How can I make the dialog to use two scrollbars in order to prevent this problem???
|
|
|
|
|
Scrollbars on a dialog are not a good idea IMHO, You would be better of breaking the dialog into smaller related peices and using a property sheet/pages.
P
|
|
|
|
|
Hi,
I am getting "DDE Server Window: seqncr.exe - Application Error" message, when I try to register my Exe application.
Note: seqncr is my exe name
I tried using seqncr /REGSERVER at the command prompt to register the exe.
I am getting this error only for Release version, not for Debug version.
Can anybody help me out with the various reasons, whcih will cause this error.
Thanks lot in advance!!
Rupanagudi
|
|
|
|
|
Anyone know a good XML Parser AND Writer Ansi C(++) class/Library. (Could not find what I was looking for on this WebSite).
Can be commercial, but preferably free.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
The Xerces parser is pretty good for parsing and manipulating the DOM. My biggest problem is that, when I last looked, you have to write your own code to save an XML file. The Xerces parser, if your curious, is located at 'http://xml.apache.org/xerces-c/index.html'.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
I'm using the latest Platform SDK from MS and have the latest SP for VC++6.0 installed on an ME platform . . . for some reason when I try to register a window class with RegisterClass() or RegisterClassEx() the call fails and GetLastError() returns ERROR_CALL_NOT_IMPLEMENTED. Does anyone know what's going on? It seems odd to me that I can't create the main class that Windows is founded on.
-Michael
|
|
|
|
|
Please be more specific - how do you initialized members of the WNDCLASS or WNDCLASSEX struct?
In the docs for RegisterClassEx, I've found the following info:
"Windows 95: RegisterClassEx fails if the cbWndExtra or cbClsExtra member of the WNDCLASSEX structure contains more than 40 bytes."
Not sure if this applies to WinME.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Sorry . . . here is my WNDCLASS struct. I've found that RegisterClass() works when compiled on VC++ without the Service Packs and without the Platform SDK upgrade.
Could there be some variable I need to #define?
MSG msg;
WNDCLASS wc;
CREATESTRUCT cs;
wc.style = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.hCursor = NULL;
wc.hIcon = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "SystemControlClass";
wc.hbrBackground = HBRUSH(GetStockObject(WHITE_BRUSH));
if (!RegisterClass(&wc))
{
#ifdef _DEBUG
DWORD dwLastErr = GetLastError(); // I check this variable in the
// debugger.
#endif
return FALSE;
}
-Michael
|
|
|
|
|
On my machine (W2K, VC++ 6.0/SP5, no Platform SDK update) it also works.
RegisterClass is #defined in winuser.h as RegisterClassA or RegisterClassW, depending on the value of UNICODE macro:
#ifdef UNICODE
#define RegisterClass RegisterClassW
#else
#define RegisterClass RegisterClassA
#endif // !UNICODE
Assuming that in your project UNICODE is definded, your program will link with RegisterClassW. I don't have ME machine, so I can't check if this OS exposes 'stub' for RegisterClassW that simply returns ERROR_CALL_NOT_IMPLEMENTED. Without the stub, your program wouldn't load - you'd get the error message box saying that loader can't find the imported function in the USER32.DLL
You can check which variant your program calls by using depends.exe. The function should be exported from USER32.DLL.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Hi.
I'd like to close an application by sending to its main window the WM_CLOSE message.
What I do is getting the ID of the process I want to stop, and then I use EnumWindows()
function to get all top-level windows in the screen and in the callback function
EnumWindowCallBack(), I compare the process ID with the ID of each top-level window.
When the ID is the same, I send to the window the WM_CLOSE message thanks to ::PostMessage().
But, unfortunately, it doesn't work all the times. It seems that the windows I get in
the callback function EnumWindowCallBack() are not the main windows of the applications
I want to stop... For example, with calc.exe, the window is closed after having posted
the WM_CLOSE message twice but the process calc.exe is still running without a window...
Has anyone already met this problem ?
Is there a way to be sure to get the right window of an application (and not a child window
that doesn't handle the WM_CLOSE message) ?
Thanks.
|
|
|
|