|
Hi Everybody,
Do any one know how to convert a file from EMF to SWF.
Thanks & Advance,
Azghar
If you have faith in cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
There is a SWF SDK, you will need to download it and learn how it works.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello,
I have a tricky situation happening in an app which loads a DLL and then tries to retrieve some procedure's addresses. Consider the following code:
void CDesktopPositionerDlg::OnCapture()
{
DFUNC_DEF(CDesktopPositionerDlg::OnCapture);
BOOL (__stdcall *lpSetup)();
BOOL bRetVal;
bRetVal = theApp.m_hModule != NULL;
if(!bRetVal)
goto loc_ret;
lpSetup = ::GetProcAddress(theApp.m_hModule, "Setup");
bRetVal = lpSetup != NULL;
if(!bRetVal)
{
DTRACE(DSTR("Could not retrieve dll function address (err.#%d)", ::GetLastError()));
goto loc_ret;
}
(*lpSetup)();
.
:
.
loc_ret:
DFUNC_RET2(bRetVal != FALSE, "Mouse hook not setup!", "Mouse hook successfully setup");
}
Now notice the call to ::GetProcAddress . If you change the name of the setup function to _Setup@0 , which is the name defined in the .LIB file, all is fine and the hook is successfully setup.
What I would like to know is the linker option (or C calling convention) I have to adopt in order to prevent such situations from happening.
As always, all comments are welcome.
David
|
|
|
|
|
I must ask, however inconvinient it sounds, what is the situation you wish to prevent ?
Are you, per chance, failing to retrieve the address of the function, unless you name the parameter of GetProcAddress to "_Setup@0" ?
How did you export the function from the DLL ? Or was it built by someone else ? Was it built with Visual Studio ? These questions are imperative, mostly because if the last answer is positive, there are two ways of exporting functions from a DLL.
If you have access to the DLL code, you should add a __declspec(dllexport) calling convention in front of the setup function. Also, create a module definition file (.DEF) inside the DLL project. Paste the following text into it
LIBRARY "MyDLL.DLL"
EXPORTS
Setup @0 When you now build the DLL, the GetProcAddress will not fail if you use "Setup" as the function name. Before, you built the DLL using the default settings. In such a case, the exported routines are added with the underscore in front of them. It is called 'behaviour by default' in Microsoft's terms. The only way to remedy it is to use a module definition file. The __declspec definition is added for increased compatibility, as in, fail-safe exporting.
Also, if you're using dynamic loading (LoadLibrary), the library file is useless. Library files generated for DLL's are only usable if static linking is used, or if the DLL contains a registered COM component (DirectX applications, for an example).
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi Antti and thanks for the reply.
Antti Keskinen wrote:
Are you, per chance, failing to retrieve the address of the function, unless you name the parameter of GetProcAddress to "_Setup@0" ?
That's it basically. After having finished the DLL I tried to access some of its functions in my MFC App by calling GetProcAddress and passing the names of the functions. It didn't work.
Well it happens that, after taking a look at the .MAP file, all the functions are added the underscores and also some additional characters. Therefore, trying to retrieve Setup 's proc address from the Dll would only work if I called GetProcAddress passing _Setup@0 .
I don't really know the workarounds one has/can do in order to prevent this from happening. I mean, how can I export the function as is, making it accessible by its true name?
Will I have to create a definition file for the Dll?
Again, thanks for the reply.
By the way, I am using the __declspec(dllexport) calling convention.
|
|
|
|
|
If you want to be sure by what name a function is exported, use a module definition file and rebuild the DLL. For example:
__declspec(dllexport) int Setup(void);<DIV>
LIBRARY "MyDLL.DLL"<DIV>
EXPORTS
Setup @1 This would export the Setup function from the DLL with it's true name, and GetProcAddress will not fail if you ask it to look for a function called "Setup". Also, using both the __declspec and the definition file is just about making sure it works. It will not get exported twice.
Also, you can rename the exported symbols in the module definition file. Assuming that Setup is still the function name inside the DLL you wish to export, the following statement under EXPORTS would rename this symbol:
Exported1 = Setup @1
Now, requesting "Exported1" with GetProcAddress would return the address of "Setup". However, asking for "Setup" would return an error.
Basically, the difference on which one to use depends on if you want a library file (.LIB) or not. The __declspec(dllexport) adds an entry to the library file, so that if you link with this library file, you can call the exported functions, and the DLL will be loaded and the function executed (static linking). However, if you use dynamic (run-time) loading, the module definition file is the only way to specify the names of the exported functions explicitly. It is not possible to use a library file with dynamic loading. This will not work, it is just not designed to work that way.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Great stuff Antti!
That is exactly what I was looking for!
Thanks a lot for the invaluable feedback, Antti.
- David
|
|
|
|
|
I would like to put the output of one of my projects in the SYSTEM32 directory but I can't find the macro to use. I'm trying to set it in the Project->Properties->General->Output Directory.
I'm looking for something similiar to $(OutDir), $(TargetDir)...
Thanks in advance,
RS
|
|
|
|
|
You can use all of the visual studio pre-defined macros, or you can use standard environment variables.
This works on my win2k box
$(SYSTEMROOT)\system32
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
|
|
|
|
|
Thanks Andrew that works fine on my win2k machine as well. I'll have to test it out on XP.
In you signature you have "If you can think - and not make thoughts you aim;"
Should it be "thoughts YOUR aim"?
Thanks again...
RS
|
|
|
|
|
Rome Singh wrote:
Should it be "thoughts YOUR aim"?
and it's been like that for almost 18 months,
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 your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi! I have a little problem
When running my mfc mdi app, I get that message from the debugger whenever my cursor flyes over certain toolbar buttons. Next to the ID, apears the buttons identifier
Those buttons have an update message handler (CCmdUI stuff) directly linked with the current CView, so their state change as you switch between views, depending on the view internal state. Buttons without update handlers don't show that behaviour
What that does the message exactly mean? On the other side, the app works ok, so it's a bit strange. I surfed the web, but no infor related to this was found.
Thanks in advance to all.
|
|
|
|
|
That's the application framework letting you know that you haven't defined a fly-by message and tooltip for the toolbar button's id. To fix the problem, define a string resource (with the toolbar button's id) of the following form:
"Command description\nTooltip" /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello,
I attach a "TREE CONTROL" in VC++.net, and add a parent and some child nodes.
It works well.
Now i want that, When i click on 1st Child, it display a Message Box with a text, "You clicked on 1st Child".
And when i click on "Second Child", it prints in a Message Box "You Clicked" on 2nd Child.
Kindly help me, that how can i do this.
Regards,
Eshban
EsHbAn BaHaDuR
|
|
|
|
|
The message TVN_SELCHANGED is generated when the selection in the tree control is changed. It gives you a pointer to the item structure which the user selected.
To capture the TVN_SELCHANGED message in MFC, write the following code inside the BEGIN_MESSAGE_MAP and END_MESSAGE_MAP macros located in the window class that is the parent for the tree control:
ON_NOTIFY( TVN_SELCHANGED, tree-ctrl-id, OnSelChanged ) Then add a member function to the class like this:
afx_msg void OnSelChanged( NMHDR * pNotifyStruct, LRESULT * result ); Then write the following skeleton for the handler function:
afx_msg void memberFxn( NMHDR * pNotifyStruct, LRESULT * result )
{
NMTREEVIEW* pTreeView = dynamic_cast<NMTREEVIEW*>( pNotifyStruct );<DIV>
CString strNodeName( pTreeView->itemNew->pszText );
} If you need to identify the items based on their ID, you need to originally store this ID as the lParam value in the TVITEM structure. It can be an integer, for example. When you store it there, you can use the itemNew pointer to get it via the lParam member . An example as follows:
pTreeCtrl->InsertItem( TVIF_PARAM | TVIF_TEXT, _T("Child node 1"), 0, 0, 0, 0, 1, hParentNode, NULL );<DIV>
int ID = (int) pTreeView->itemNew->lParam; I hope this will help you. If you have further questions/problems, post them here.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I'm having problem getting double buffering to work in MFC.
I have tried to implement it based on the information found on this page http://codeproject.com/gdi/flickerfree.asp
The problem is that I don't really understand how to "override" the OnDraw method. There are no OnDraw method in the code that was generated when I created the project, and I have tried to just add the method in there but it's never called.
I'm using Visual C++ 7.0 (.net) and the ClassWizard that is mentioned on a lot of examples regarding this issue seems to be removed from the new version of Visual Studio.
I would be greatfull for some pointers on how to do this.
|
|
|
|
|
What is the project type you created ? A MDI application ? An SDI application ? A dialog project ? The OnDraw method is only there if you are handling a class based on CView . CView::OnDraw is a virtual function that you can override in order to define custom behaviour.
The concept of overriding is related to the object-oriented programming model. Consider that you have a class, call it class Alpha, for now. Class Alpha has a member function called Func1 that is declared as virtual. If you derive a class called Class Beta from Alpha, and write a function called Func1 in there, this new function will override the old Func1 from Alpha.
In the MFC world, the class thinking is at large. What OnDraw does is answer to WM_PAINT windows message.
The Visual Studio .NET doesn't boast ClassWizard anymore. It is replaced by a more functioning event list in the Properties of the class. I assume you know how to use the Class View, which shows all the classes your project contain. In this view, right-click on the class name you wish to write a message handler to, then select 'Properties'. In the properties view, look for a row of buttons in the top section. From these, find one which gives a tooltip 'Messages' or 'Events'. Click on it. A list of Windows messages you can react to is displayed. Find 'WM_PAINT', and write 'OnPaint' into the box next to it and press enter.
Now write the code to first create a CMemDC, and draw your stuff there. Then destroy the CMemDC or let it go out of scope, and it will blit the new graphic into the target device context.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
It's a dialog project. Basicly I have a bitmap image that stretches as the background when the window is resized,
and I don't want it to flicker when I resize the window. The bitmap is drawn in the OnEraseBkgnd method, I dont know if that is all that clever but...
I have moved the drawing to the OnPaint() method. Should I call Invalidate() in the OnResize() method to for an WM_ONPAINT event?
|
|
|
|
|
Hello.
I try to Open CDaoDatabase object in Windows XP (the user has the Excel
2000), and I use the "Excel 8.0" connect string. It returns the following
error "Couldn't Find Installable ISAM". BUT the same code works in Windows
2000. I tried the "Excel 9.0" and "Excel 10.0", but without success...
CDaoDatabase* p_daoDB = NULL;
p_daoDB = new CDaoDatabase;
p_daoDB->Open(_T("SCCardOS.XLS"), // file name
FALSE, // exclusive
FALSE, // read only
_T("Excel 8.0;")); // connect string
I found the post with the same problem, but without solution ;(
I need some tips for solving...
Thank you in advance.
|
|
|
|
|
Hi there,
i want to know some things regarding process in windows. how to hide a process name. i know there is a sample in codeproject. i want to know what are the steps or what is logic behind it. what is the process difference in windows 95 series and windows nt series.
and how to hide my appication icon that comes up when you press alt+tab. in that small dialog your app icon shows up if there is more then one app running. can i remove my icon from there.
reagrds
swarup
|
|
|
|
|
Hi,
how can I add a toolbar on a view, and not the mainframe ?
|
|
|
|
|
How can I export my class in "Regular DLL that statically linked MFC"?
My class does NOT inheritance from CObject.
But it use MFC class such as CString.
Also if my class inheritance from CObject, how can I do it?
Thanks
|
|
|
|
|
I have a dialog in my application that I want to be shown in the taskbar (it's not the main window). I do this by calling this in OnInitDialog:
::SetWindowLong( m_hWnd,
GWL_EXSTYLE,
GetWindowLong(m_hWnd, GWL_EXSTYLE)|WS_EX_APPWINDOW
);
This works quite well but there is one minor bug. If that dialog has a children, for example a message box, the message box doesn't get the focus when the user click on the button in the taskbar. Instead the dialog receive the focus. If the user use Alt+Tab or trying to click on the dialog, the message box gets the focus as expected. Any suggestion how to solve this?
I'm using VC6 and have tested this in NT4.
|
|
|
|
|
You need to ensure that the parent window of the message box is the dialog.
Software Zen: delete this;
|
|
|
|
|
Thanks, but I get it same result if I do this:
::MessageBox( m_hWnd, "Bla bla bla", NULL, MB_OK);
I have checked with Spy++ and the handles are set up correctly.
However, I have found a workaround. I handle the WM_SETFOCUS message in the dialog. If the dialog gets focus and the window isn't enabled, it tries to change the focus to the popup window:
LRESULT CDialog2::OnSetfocus(WPARAM wParam, LPARAM lParam)
{
if(!IsWindowEnabled())
{
HWND child = ::GetWindow(m_hWnd, GW_HWNDPREV);
if(child != NULL)
{
TRACE(_T("Has child!\n"));
::SetFocus(child);
}
}
return 0;
}
I don't like this solution sense I doesn't understand what's going on, but I guess I could live with that.
|
|
|
|
|