|
I have to keep a few extra bytes in a data file when it is being created. But when the file is finished, these bytes have to be thrown away. I cannot have another copy of the file since it may be huge, and I have to put those bytes in the file for it may be moved away or deleted. That means I have to shorten the file.
I'd be very thankful for any good idea about truncating a file.
Tiny Flying Elephant
I love flying...
|
|
|
|
|
|
Setfilesize may do the same work!
Please pardon my weak English!
|
|
|
|
|
I have a hook dLL that I'd like to send a message back to the calling app.
Something like......
keyboard hook detects that F2 is pressed
dLL sends message to app
app shows dialog
main code in dLL as follows
///////////////////////////////////////////////////////////
#define WM_APPSTARTED WM_USER + 100
#pragma data_seg(".shared")
HWND g_mainWnd = NULL; //the server window handle
HHOOK g_hShellHook = NULL;
HHOOK g_hKeyboard = NULL;
#pragma data_seg()
#pragma comment(linker, "section:.shared,rws")
SYSDLL_API BOOL _Startup(HWND hwnd)
{
g_hKeyboard = NULL;
g_mainWnd = hwnd; // g_mainWnd is the main window handle
g_hKeyboard = SetWindowsHookEx(WH_KEYBOARD, MyProc, g_hInstance, 0);
if(g_hKeyboard == NULL)
MessageBox(HWND_DESKTOP, "hook fail", "BLAH", MB_OK);
if(g_mainWnd != NULL)
return FALSE; // already hooked!
g_hShellHook = SetWindowsHookEx(WH_SHELL, MyShellProc,g_hInstance, 0);
if(g_hShellHook != NULL)
{
g_mainWnd = hwnd;
return TRUE;
}
return FALSE;
}
SYSDLL_API LRESULT CALLBACK MyShellProc(int ncode, WPARAM wparam, LPARAM lparam)
{
if(ncode < 0 )
return CallNextHookEx(g_hShellHook, ncode, wparam, lparam);
if(ncode == HSHELL_WINDOWCREATED)
{
HWND hfoundApp;
hfoundApp = FindWindow(NULL, TEXT("my_window" ) );
if(hfoundApp)
{
PostMessage(hfoundApp, WM_APPSTARTED, lparam, wparam);
}
}
this is where I'd like the dLL to send a message to the callin app
but the message never gets to the app
thanks for your time
|
|
|
|
|
Hi,
I am a beginner in MFC and I am working on the tab controls. However, I don't really know how it works. Can anyone demonstrate to me how to use it?
thank you
|
|
|
|
|
(In VC6.0,using MFC)
I created a list control(by CListCtrl).Here,i met a little problem
:i input a string,then i told the list control to search in its items whether there's a item contains it.If
there's one does contains,how can i highlight this item and scroll the window automaticly to make the item appear on my screen?
God blessing me...
|
|
|
|
|
Try this:
int viFoundThisItem = 4;
m_ctrlMyList.SetItemState(viFoundThisItem, LVIS_SELECTED, LVIS_SELECTED);
m_ctrlMyList.EnsureVisible(viFoundThisItem, FALSE);
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
I don't want keep on asking so many questions, so is here has something like faq which has already collect most question asked here and answer. that would be great.
|
|
|
|
|
The FAQ link is just above this post, on the right hand side, in the orange bar.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
http://www.codeproject.com/useritems/cppforumfaq.asp
Copy/paste that into Start-Run
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
there are some misunderstand, the faq on the top is talk about how to deal with this message board. i just want a faq that collect the question&answers on this message board about vc programming.
|
|
|
|
|
Gosh! Scroll down man...
It is titled " Mike Dunn's C++ FAQ ".
You seriously dont think that he'd name it that if it was a FAQ about the Lounge.
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
Hi,
I want to teach myself COM, I'm an experience Visual C++/MFC progammer, can anyone recommend a book?
Thanks,
Stuart
|
|
|
|
|
Well there are two approaches:
COM is a model or a paradigm, and the developers that I have met that have read and understand the theory, go alot farther, and are able to do alot more with COM. Therefore I would recommend Don Box's book on Essential COM for theory.
You are notreally going to absorb it until you practice it. I do not have any books that explain COM in MFC, except Jeff Prosise's Programming Windows with MFC, however, it only glosses over the topics.
If you are interested in ATL, which I think is a cleaner way of programming with COM since that is what it was conceived to do, then I would recommend Brett Rector's and Chris Sells' ATL Internals.
With these two books and all of the examples in MSDN, I have had no problem learning anything that I wanted to do in COM.
|
|
|
|
|
Hi guys
when i execute this code
void main ()
{
float x=3/2;
cout<
|
|
|
|
|
Mohe wrote:
float x=3/2;
A computer is only smart enough to operate on two items at a time. If you break your statement in question down into its simplest parts, 3 is an integer, and 2 is an integer. When the compiler performs an operation on these two numbers, it does integer division which results in 1.
In order to fix this, make one or both of the parameters floats like this:
float x=3.0 / 2;
float x=3 / 2.0;
float x=3.0 / 2.0;
Then you will get the result that you expect.
|
|
|
|
|
How can I modify an environment variable such that the changes are made to the registry, so that they are propagated to others when system restarts or some new application starts? The SetEnvironmentVariable API updates the environment for the current process only.
Thanks,
Krishnan
|
|
|
|
|
Hello Krishnan,
I have a suggestion for you : on a Windows NT machine, you can try modifying the following registry entry :
"HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
Search for the environment variable you want to modify and make the necessary changes.
Best Regards,
Bio.
|
|
|
|
|
Hi,
I have a worker thread for some file processing, the status of which I wanna display on a Progress dialog.
I took advantage of the built in progress dialog in Add To Project/Components and Controls.
I create and manipulate the Progress dlg in the worker thread using the pointer to CProgressDlg passed from AfxBeginThread's 2 parameter to the worker thread.
Problem: the Progress dialog has very slow responsiveness to buttonclicks as if there were no threads involved at all.
What's wrong?
Thanks
Bunburry
|
|
|
|
|
Each thread should have it's own message loop. Maybe your implementation does not?
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
the built-in progress dialog has its own message pump which is automatically called by every StepIt or SetPos.
ASSERT(m_hWnd!=NULL);
MSG msg;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(!IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
This is meant...
Bunburry
|
|
|
|
|
Case solved.
I will always remember to call
if (pProgressDlg->CheckCancelButton)
pProgressDlg->DestroyWindow();
in the loop of my worker thread.
Thanks anyway for your help.
Bunburry
|
|
|
|
|
Hi,
I'm beginner for thread process. Does anyone know any good and easy tutorial about thread (or multi-thread???).
Actually, I need to do write a program to simulate the Locking System in DBMS. Just simulate and no SQL or DBMS required. And I think i need to use thread to implement it. But I know nothing about thread....
Can anyone help me????
THANKS A LOT!!!!!!!!!!!!!!!!
|
|
|
|
|
This CP article may help.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
As a starter, you might want to take a look at CP Threads, Processes & IPC section. There are a couple of tutorials on multithreading there.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|