|
your question is kinda strange..
you hook apis by creating a dll, which has some of the original functions, and then you redirect these calls to your own dll.
so where is the problem?
Don't try it, just do it!
|
|
|
|
|
The problem is that when I only implement some and not all of the API exported by the original DLL the executable will complain about missing external references.
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Anyone experienced any problems (memory leaks in my case) with Windows Media Format SDK? I'm using it to retrieve content from network and write to local disk, but looks like it has a memory leak. This is the code I use:
IWMReader* pReader = NULL;
m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
HRESULT hr = WMCreateReader(NULL, WMT_RIGHT_PLAYBACK, &pReader);
pReader->Open(L"some_url_here", this, NULL);
WaitForSingleObject(m_hEvent, 60000);
pReader->Close();
pReader->Release();
CloseHandle(m_hEvent);
Both callback functions (OnStatus and OnSample) are empty, just returning S_OK. You see, I'm not starting it, only opening. After I call Open function, memory jumps for about 2.5Mb. When I call Close and Release it goes down around 1.Mb, leaving 1.5Mb in "air". Anyone knows about this?
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Is the memory usage going up by 1.5MB for every file, or just the first? If it's just the first then that's normal. The first time you use any in-proc COM server, your process has to load the server DLL (and any others that it uses) so your working set will increase.
If the working set is an issue, call CoFreeUnusedLibraries() to try to unload in-proc servers with a ref count of 0.
--Mike--
Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Well it happens every time I create and open IWMReader. For example (not the full code, just to keep it simple):
WMCreateReader(NULL, WMT_RIGHT_PLAYBACK, &pReader);
pReader->Open(L"URL");
pReader->Close();
pReader->Release();
put this in loop and you get the memory to 100Mb in just a few minutes. But if you won't call Release (and of course won't create it again), mean just Open and Close, then everything is ok. I'll try your suggestion though tomorrow at work. Will see if this is the problem. Thank you
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Philip Patrick wrote:
put this in loop and you get the memory to 100Mb
hmmm, that is worrysome. Which version of the FSDK? I use the FSDK at work, and it's possible that a user could end up doing similar code in a loop over many files, so I'll give it a try at work tomorrow too.
--Mike--
Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
Using the latest version. But...
Now it is something I don't understand at all. The "memory leak" is really depend on the source. I found sources that the same code doesn't produce any leak and sources that it does (all of them have a video stream). Not sure what happens here.
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
I need to retrieve data from 2 tables which one of the fields is a total. i use my own recordset(which inherit from Crecordset ), and i bind the coloms in DoFieldExchange.
now i need to get the field from my recordset but the field which contain the sum function retrieve 0.
This is my select from the 2 tabels tPlan and tUser :
(SELECT tPlan.ID, Sum(tUser.SpaceUsed) AS SumOfSpaceUsed,FROM tPlan INNER JOIN tUser ON tPlan.ID = tUser.PlanID
GROUP BY tPlan.ID;)
i use this way:
void CPlanUserSet ::DoFieldExchange( CFieldExchange* pFX )
{
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Int (pFX,"tPlan.ID",plan_user.m_Pid);
RFX_Int (pFX,"tUser.SpaceUsed",plan_user.m_SpaceUsed );
}
The id field is retrieved but not the Sum of spaceUsed
Any idea????
|
|
|
|
|
Hmm. Got a couple suggestions for you. Might seem really simple so you've probably tried them already, but I'll throw them out there anyway.
The most obvious reason that appears to me is that in RFX_Int for the SpaceUsed you are using "tUser.SpaceUsed". I might be wrong here, since I've never used RFX, but shouldn't that be "SumOfSpaceUsed"?? Since thats what it's saved as in the sql statement.
The only other thing I could think of is that SpaceUsed isn't a number in the database, but it'd probably throw an exception if that was the case.
Mike
|
|
|
|
|
Hello, i want to make a simple program basically doing this:
- system will go to full screen (complete full screen).
- i will put different images on the screen from image files whenever i want,
- if possible i will put animated gifs on the screen.
what would you suggest? is there any very simple example for doing this kind of application than you can give me a link?
Thanks.
|
|
|
|
|
Here's a link to a minimalistic application that creates a new window, paints it black and makes it fullscreen. It is an MFC style solution, using pure MFC methods to do it's work.
http://www.tpu.fi/~t1akeski/FullScreen.zip
It's is heavily commented for easy following. If you wanted to put images to the screen, just look for an article explaining how to BitBlt bitmaps to the window DC. There are many tutorials available on that issue.
In other news, does someone know if there is a bug in the MFC documentation. When I call the CreateEx routine, and pass a CRect as it's size, then the declaration of the function states that I should provide a ID for the window. If I specify this ID to something else than zero/NULL, the app causes an assertion. If I didn't use CRect, the ID parameter would be replaced with some menu handle, suggesting that I should put NULL to it. And if I pass NULL to the ID (when using the CRect version), it works smoothly. Strange, no ?
Greetings,
Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
When I used copyfileex, I'm marshalling an interface for use in the callback. What I want to make sure is that if the user cancels the copy, that I get a notification that (final step e.g.) the Copy has been cancelled coming into the CopyProgressRoutine, so that I can release the necessary interfaces.
Am I missing something, or do I not have to marshall the interface for use in the CopyFileEx scenario?
|
|
|
|
|
CopyFileEx is not a COM method, it's just a plain stdcall API function. Same thing with it's callback, there's no interface there at all, just a function pointer to a stdcall function. Nothing to marshal.
-Blake
|
|
|
|
|
Hi,
I have looked for a solution with google/this site etc, but to no avail...
I am looking for a means of creating an image and having hotspots within that image. I want to be able to click on an area of the image and generate a message from that. Within the image I wish to have several such areas. The point is to use this as part of a spatial sorting hierachy, where objects are sorted according to area (assume for the purposes of the argument into rooms). This is the best means of displaying the data to the user, rather than using some form of TreeView.
I assume I could define regions by using the gdi and then using a mouse point to test for intersections with that region. Is there another method, or has this been done before. I don't want to be reinventing the wheel.
Any ideas or suggestions will be gratefull received.
Thanks for your help,
John
john_tipper@hotmail.com
|
|
|
|
|
I hate to suggest the obvious, but how about using the web-browser control?
There are some good articles on CP on how to do this.
Using the WebBrowser control, simplified[^]
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
I've created a tree control with TVS_SHOWSELALWAYS set. However whatever I do, the control doesn't want to show or update the selection if it doesn't have focus...
Is there some caveat I'm not aware of? Do I have to create a custom-draw control just for this? I'm beginning to think it might be easier...
|
|
|
|
|
Hi there !
I made a few searches through the articles and through the board, but didn't manage to find an answer.. If there is already an answer to this, just post the link
So, I have a CCtrlView-derived class, CTabView (No, not a co-incidence). This class is responsible for upkeeping a Tab control (Created through CCtrlView's constructor) and an array of CViews. Now, when you wish to add a new view to the tab, it requires you to insert a pointer to your CView-derived class through the RUNTIME_CLASS-macro. After that, it checks if the run-time info you specified is indeed a CView-derived, and creates a new object based on this info with CRuntimeClass::CreateObject.
When the creation is done, it creates and attaches a new view to this object by casting a pointer to the CView-class and calling it's Create-method. Then, it saves the CView-pointer to a CObList for further use.
When quitting, the application goes through the list and calls each CView's DestroyWindow in succession until the list is clear. After that, it posts a OnDestroy-message to the underlying CCtrlView which destroys the tab control.
But the problem is that when I build & run this app, it works smoothly until the quit phase. There, it causes an assertion. What am I missing here ? Should I use 'delete' on each of the pointers after DestroyWindow as well ? Can it be done ? What, exactly, does CreateObject do when it builds an object from the run-time info ? And if 'delete' is not the answer, what is ?
Or shouldn't I delete the views at all, but let "The Framework" work it out ?
Of course, if someone already has a functioning Tab control which accomplishes the above mentioned smoothly, a link is again appreciated
Thanks in advance,
Antti Keskinen
EDIT: The 'delete' operation did no good, the app still asserts. For additional info, I am using a splitter window to where my derived control view is loaded to. Debugging reveals it is XTreme toolkit's CXTPFrameWnd, which causes the assertion.
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
hello, i am new to MFC, and i am trying to implement a very simple Timer it does not work.. i create the most basic MFC project with the wizards, code is like this:
in MainFrm.cpp
----------------
void CMainFrame::OnStartTimer ()
{
mTimer = SetTimer (1,1000,0); //1 sn intervals
}
void CMainFrame::OnTimer (UINT_PTR ptr)
{
MessageBeep (MB_ICONEXCLAMATION); //make a sound
}
in MainFrm.h
----------------
...
public:
void OnStartTimer(void);
...
protected:
afx_msg void OnTimer (UINT_PTR);
....
i try to call the OnStartTimer from the project.cpp file after the creation and painting of the MainFrm object, indeed it goes to the OnStartTiner() function but system never calls the OnTimer function. what i am doing wrong?
(i use VC++ in Studio.Net 2003)
Thanks.
|
|
|
|
|
Go check your 'MainFrm.cpp'. In the top of it, locate a 'BEGIN_MESSAGE_MAP' - 'END_MESSAGE_MAP' pair. Between these two lines, look for 'ON_WM_TIMER ()' entry.
If this entry doesn't exist, add it manually between the linepairs, so that your code looks like this:
<br />
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)<br />
....<br />
ON_WM_TIMER ()<br />
...<br />
END_MESSAGE_MAP()<br />
The '...' mean other entries in the message map. Do not modify these, if there are any. Just add an empty line and write your new entry there.
Now, whenever a WM_TIMER -event occurs, the function 'OnTimer' gets called.
If the timer still refuses to co-operate, start Microsoft Spy and look for messages sent to your application when it is running. If you don't see the 'WM_TIMER' messages popping in there regularly, then your SetTimer-function fails to create a timer. If it displays 'WM_TIMER' messages, then see below.
Remember to add the 'KillTimer' function call to the end of your application. If you leave the timer ticking after your window is destroyed (done by the Framework), future timers may behave incorrectly. A reboot helps remove unwanted timers if they've been left.
Greetings from,
Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks a lot fo the help! very clear and detailed answer!
|
|
|
|
|
Hi,
How do I access a Global variable of one Dialog box from a another one.Some suggested sending messages, but how do I send a variable using sendmessage? anone line example would be great.
Thanks
Deepak Samuel
|
|
|
|
|
One solution is to send a pointer. Another solution is to declare the global variable using extern inside, for example, stdafx.h.
Kuphryn
|
|
|
|
|
If the second dialog box is modal, then you can add a variable fo the same type as the global variable in your dialog's header file - in the public: section.
Then when you instantiate your second dialog box, you can assign the value of that dialog's variable:
CMyDialog dlg;
dlg.TheLocalVariableIWantToBeTheSameAsTheGlobalVariable = GlobalVariableValue;
dlg.DoModal();
|
|
|
|
|
In Fact the simplest way to do this is to have a parent class handle the variable so that both dialogs can access the variable, regardless if they are modal or modeless dialogs. For example if both dialogs are displayed from a handler in the MainFrame class, have the mainframe class contain the variable, make the variable public (or better still add functions to get and set the variable), then pass this into the dialog classes when they are created, then either dialog can call GetParent()->(variable name) or GetParent()->(function name).
As an alternative to this you can make a third class that is soley used for holding data (e.g. not a display class), this could then hold the data to change, and both dialogs could hold a pointer to this class and then they can access the variables and functions of that class.
Mark.
|
|
|
|
|
Hello,
how can I create a Folder (for example: "MyPersonalFolder") under an existing Folder such as "Inbox".
Actually I can create a folder on the same rank as for example the "inbox".
Thanks a lot for helping me !
|
|
|
|
|