|
hi
i need to know how can i extract a clip of specific duration out of an avi file
|
|
|
|
|
Because macros are preprocessed prior to code execution, is it possible to change the value of a variable that a macro uses, after the program has started? Here's sample code.
#define ADD_THIS_COMMAND(f, d) CMD_FUNCTION(f); SymCommand cmd_##f(#f, d, f) Is it possible to change (by way of the program) what 'd' in the macro represents, after the program has started? (For example, if 'd' at the beginning, symbolizes the word, "Dollars", could you afterwards from inside the program change it so that the next time the macro gets executed, it would symbolize, "Pesos"?)
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
Macros are always a sign of a bad programmer, or a bad design - Bjarne Stroustrup.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
That's fine for Stroustrup to say. He is not down there in the trenches with his sleeves rolled up, handling the dirt and the mud.
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
He is not down there in the trenches with his sleeves rolled up, handling the dirt and the mud.
That's because he has less dirt and mud to deal with - he doesn't use macros )
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello,
It's NOT possible to change the macro or anything that has to do with the macro (the compiler never sees the macro)! There's a simple explanation for that.
exemple:
you have this code
<br />
#define MACRO(a) cout << a << endl;<br />
MACRO("zzz")<br />
MACRO("bla")<br />
MACRO("drink coffee")<br />
after preprocessing, the code go's to the compiler. The code the compiler sees is:
<br />
cout << "zzz" << endl;<br />
cout << "bla" << endl;<br />
cout << "drink coffee" << endl;<br />
Hope this helps
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Thanks for replying.
The more I think about it, the more you make sense about what you said. Thanks.
William
Fortes in fide et opere!
|
|
|
|
|
i want to get some information about a remote machine.
so wmi(Windows Managment Instruments) can provide what i want.but i don't if it can access wmi on a remote machine outside of lan network by ip.
who can tell me?thanks?
Habbit--Beginner In MFC
|
|
|
|
|
I have Visual c++ dialog application . once the dialog has been created immediately I need to show a File Dialog .
Doing it in OnInitDialog doesnt work as expected as it pops up the file dialog .
Is there some other point where i can make this call
or do i have to have some internal variable that a timer checks after a while and then shows the dialog ?
Engineering is the effort !
|
|
|
|
|
Well there's a few ways to tackle this problem. Indeed you could use a timer. But the most important thing for you to understand is how message queues in Windows work. However, first the answer to your question. Try creating your own custom message ad handler for it first therefore at the top of your dialog CPP file...
#define WM_MYOWNMESSAGE WM_USER + 1001;
... Then in the header file put...
afx_msg LRESULT OnMyOwnMessage(WPARAM wParam, LPARAM lParam);
...Then the appropriate body for it...
LRESULT CMyDialog::OnMyOwnMessage(WPARAM wParam, LPARAM lParam)<br />
{<br />
... Show the file dialog box (I know it has to be modal)<br />
return 0;<br />
};
... And finally in the body put...
ON_MESSAGE(WM_MYOWNMESSAGE, OnMyOwnMessage)
... in the BEGIN_MESSAGE_MAP section...
... To call the message handler put this in the OnInitDialog function just before it returns...
PostMessage(WM_MYOWNMESSAGE, 0, 0);
So okay, this should work. But why should this work? You could do the same thing with a timer (Its another message WM_TIMER). Well as you well know OnInitDialog gets called when all the handles for all the windows you are creating are created but not shown. We post a custom message on to the message queue of the dialog box. This eventually gets processed. As I'm placing it on the message queue in OnInitDialog it will only get processed after this point in which the dialog box will be shown. I'm sure there are other ways but I find this one works very well for me :!)
|
|
|
|
|
typedef DWORD (WINAPI* ProcGetModuleFileNameEx)(HANDLE,HMODULE,LPTSTR,DWORD);
ProcGetModuleFileNameEx pfnGetModuleFileNameEx = (ProcGetModuleFileNameEx)GetProcAddress( hModule, "GetModuleFileNameEx" );
GetLastError = ERROR_PROC_NOT_FOUND!!!
The hModule is valid, I can get other functions addresses allright but this one is not working... Any idea??
Thanks!
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
Ok,
using "GetModuleFileNameExA" is working, but is this safe??? My app isn't supporting Unicode since I have to support good ol' Win 98
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
There are just the "A" and "W" versions of routines that need character strings. What you did was correct.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Is there a way to determine the size of the rendered content of a CDHtmlDialog?
- Rob
|
|
|
|
|
1.Get IHTMLDocument2 interface with GetDHtmlDocument
2.Get entire body tag with spDoc->get_body
3.Call spBodyElement->offsetHeight and spBodyElement->offsetWidth to determine the body element's size (i.e. that of the full HTML page)
4.Resize your dialog with CWnd::MoveWindow accordingly
Problem of above approach: you first show, measure and then resize your HTML, which entails some flickering.
To avoid it, first of all parse your HTML from file or resource without displaying it as described in
http://www.codeproject.com/internet/parse_html.asp
(equivalent to 1./) then do steps 2./ 3./ and 4./ in "silent" mode.
Peter Molnar
|
|
|
|
|
Hrm. That seems to return the size of the client area, not the size required to display the document.
I have the following in my class derived from CDHtmlDialog, in an overridden ShowContextMenu() handler.
<br />
LONG nHeight, nWidth;<br />
IHTMLDocument2 *pDocument;<br />
IHTMLElement *pElement;<br />
<br />
GetDHtmlDocument(&pDocument);<br />
pDocument->get_body(&pElement);<br />
pElement->get_offsetHeight(&nHeight);<br />
pElement->get_offsetWidth(&nWidth);<br />
<br />
TRACE("Document width = %d\n", nWidth);<br />
TRACE("Document height = %d\n", nHeight);<br />
<br />
pElement->Release();<br />
pDocument->Release();<br />
<br />
CRect rect;<br />
GetClientRect(&rect);<br />
<br />
TRACE("Client width = %d\n", rect.Width());<br />
TRACE("Client height = %d\n", rect.Height());<br />
<br />
ASSERT(nWidth == rect.Width());<br />
ASSERT(nHeight == rect.Height());<br />
The width and height are always equal to the respective attributes of the client rectangle.
Using the technique from http://www.codeproject.com/internet/parse_html.asp, the document width and height are always 0.
Am I missing something?
|
|
|
|
|
Sorry, I was wrong when I suggested that you should get the entire body, because its sizes really equal to the entire body, consequently you cannot get anything else but the size of your entire DHTML client area in this way.
So, my new suggestion is that you take a pointer to that element only, the size of which you wanna get.
If you are interested in several elements at a time like <a>,<img> <table>etc. then put them all into one single <div> element, and deal with this container of elements.
In order to get a pointer to an element you can either
1.loop through all elements by checking for some property, like id, name, tagname etc., using IHTMLDocument2::get_all, and IHTMLElementCollection::item,(>=IE4), or
2.use IHTMLDocument3::getElementById, getElementsByName or getElementsByTagName (>=IE5)
The simplest thing is to give your element in question (or container element) an id attribute, e.g.
<div id="YourDivID">...</div>, so that you can find it.
Remark to your code: consider using smart pointers, which makes your task significantly easier by eliminating QueryInterfacing and releasing pointers.
CComPtr<IHTMLDocument2> spDoc;
MSHTML::IHTMLDocument2Ptr spDoc;
Your code:
MSHTML::IHTMLElementPtr spElem;
MSHTML::IHTMLDocument3Ptr spDoc3(spDoc);
spDoc3->getElementByID(CComBSTR("YourDivID"),&spElem);
spElem->get_offsetHeight(&nHeight);
spElem->get_offsetWidth(&nWidth);
Peter Molnar
|
|
|
|
|
That seems to work after the content is displayed (i.e. OnDocumentComplete()), but using the offscreen rendering technique, the width and height still return 0.
I am still interested to know how to determine the width and height of an offscreen HTML document, if you have any suggestions.
However, thank you for answering my original question!
|
|
|
|
|
I am glad the second suggestion worked!
As for the the offscreen method, 2 thoughts:
1.According to your experience, a not shown HTML window has no sizes. This might be surprising at first sight but it is quite obvious at the second: how a text is rendered in a HTML container window, depends on the current window's width and height, unless you specified some style either for the whole doc or just for the given element. If the window has no size, no rendering is possible.
MSHTML::IHTMLStylePtr spStyle;
spElem->get_style(&spStyle);
spStyle->get_width(...);
spStyle->get_height(...);
This actually gets the stylesheet's current width and height data as seen from the element, but there is not much chance that it will show any realistic sizes if you didn't specify any such style beforehand.
2.Create an invisible child window on your DHTML dialog from activeX, and do on it whatever you wanted to in an "invisible" manner. Such a window should have a width and a height, as result of which a text is supposed to be rendered.
Peter Molnar
|
|
|
|
|
Here is a working code that resizes dialog window to the size of the body. Note that you should set body margin to 0 (e.g. with CSS).
Note that if you would want to also set width then you would have to set it first and recalculate and set height afterwards.
void CYourDialogClassDlg::OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl)
{
CDHtmlDialog::OnDocumentComplete(pDisp, szUrl);
LONG nHeight;
IHTMLDocument2 *pDocument;
IHTMLElement *pElement;
GetDHtmlDocument(&pDocument);
pDocument->get_body(&pElement);
pElement->get_offsetHeight(&nHeight);
LONG nHeightDiff;
CRect rectClient;
GetClientRect(&rectClient);
CRect rectWindow;
GetWindowRect(&rectWindow);
nHeightDiff = rectWindow.Height() - rectClient.Height();
SetWindowPos(NULL, 0, 0, rectWindow.Width(), nHeight+nHeightDiff, SWP_NOMOVE | SWP_NOZORDER);
}
Of course you'll also need declaration in your h:
virtual void OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl);
Nux
|
|
|
|
|
Hi
I want to draw icons from a file(.ico)
I tried this :
CDC *pDC=GetDC(); <br />
HICON m_Icon=AfxGetApp()->LoadIcon("c:\\MyIcon.ico");<br />
pDC->DrawIcon(335,25,m_Icon);<br />
DestroyIcon(m_Icon);
But it did not worked.
|
|
|
|
|
m_Icon needs to persist as long as the application. If this is a dialog-based application, make m_Icon a member of the dialog object.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
if you want to load icons at runtime the you will have to use function LoadImage see on MSDN
LoadIcon only Loads image that are added to the resources at complie time
|
|
|
|
|
I am using WM_KEYUP event for Dialog Box.
The event doesn't register.
I am looking for some simple VC++ code
to get keyboard event in the Dialog Box.
Regards
Smith
Smith
|
|
|
|
|
I tried the same thing a while back. And it does seem that WM_KEYUP messages do not get processed. Who knows? A solution to your problem is a simple keyboard hook. This makes it very reliable to get all keyboard messages back. All it involves is a simple call to SetWindowsHookEx and a call back function for the handling the keyboard messages. Here's a link to a code project article that answers this problem...
http://www.codeproject.com/dll/keyboardhook.asp?target=keyboard%7Chook
|
|
|
|