|
Would you be so kind as to passing me that VBA reference you're talking about? I'd like to learn something from this thread also
Congratulations and good luck with your project.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Gérald Mercet wrote:
"Entry point" Maximum of a dll which cannot be found in D:\essai2\Debug\essai2.dll.
THAT IS YOUR PROBLEM...
VB is a little fastidious for find functions in a dll....;)
You need to declare the EXPORT in the .def file
EXPORTS
@10 Maximum
Include the .def file in your project and ready.
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
as you ask me yesterday, sorry to be late, but when you post it i believe that it wasn't the same hour in my office than in yours!
so you could see the following code C++ and VBA, for the moment it works, but perhaps you could think that it needs modifications?!?
// essai2.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "essai2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
/////////////////////////////////////////////////////////////////////////////
// CEssai2App
BEGIN_MESSAGE_MAP(CEssai2App, CWinApp)
//{{AFX_MSG_MAP(CEssai2App)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEssai2App construction
CEssai2App::CEssai2App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CEssai2App object
CEssai2App theApp;
extern "C" __declspec(dllexport) COleDateTime WINAPI Maximini(COleDateTime a,COleDateTime b)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
COleDateTime max;
if(a
|
|
|
|
|
Gérald Mercet wrote:
so you could see the following code C++ and VBA, for the moment it works, but perhaps you could think that it needs modifications?!?
Because you are declaring the function in this way..
Public Declare Function Maximini Lib "D:\essai2\Debug\essai2.dll" Alias<br />
"_Maximini@8" (ByVal m1 As Long, ByVal m2 As Long) As Long
If you use a .def file you will can declare the function in the following way:
Public Declare Function Maximini Lib "D:\essai2\Debug\essai2.dll" (ByVal m1 As Long, ByVal m2 As Long) As Long
If your code works fine, great, but with my way you don't need to look for the internal name in the dll. That is the unique difference...
Gérald Mercet wrote:
as you ask me yesterday, sorry to be late, but when you post it i believe that it wasn't the same hour in my office than in yours!
Not problem: I live in South America, And we have several hours of diffence, and plus I'm in vacation, only I am in CP, because I can't live without CP.
Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I have a MDI application of CListView.
One of the listviews has a maximum of 20 entries(rows) with various column data and settings.
In one of the settings I would like the user to configure a keyboard accelerator key or hotkey for each row. When the user double clicks on a row a dialog box opens which allows the user to enter the hotkey in an EditBox.
I have read about ACCEL table, CreateAcceleratorTable, TranslateAccelerator and PreTranslateMessage, but is does not make sense to me at this time.
Can someone please show what the code for this look like.
Thanks
|
|
|
|
|
I don't know if got your problem well,but first you can ovverriden NM_DBCLK of your view,and inside it create your dialog class,and in your dialog class use WM_SETHOTKEY or WM_SYSCOMMAND
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
Thanks. I do appreciate you input.
I still have no joy though. I read the info on the MSDN but it makes little sense to me. The sample code are not relevant to MFC. It could be that I do not have the latest MSDN Cds.
I am not sure whether I am way off the tracks,
but would appreciate any help on this.
This is what I have in mind at the moment :
typedef struct _Accel
{
BYTE fVirt;
WORD Key;
WORD cmd;
}Accel;
class MyListView : public CListView {
public :
Accel *pAccel;
HACCEL haccel;
int count; // number of hotkeys can be defined
.....
};
// in the CPP file
// in class constructor
void MyListView :: MyListView ()
{
count = 20;
haccel = CreateAcceleratorTable(pAccel, count);
}
void MyListView :: OnDblclk (...., ....)
{
// assign hotkey string to structure
...
// I DO NOT KNOW HOW TO ASSIGN THE HOTKEY TO THE PARTICULAR ID RESOURCE NAME
...
}
void MyListView :: OnKeyDown (....)
{
// read the key being pressed and activate the neccessary toolbar button
HOW IS THIS DONE
}
// DestroyAcceleratorTable when application closes
...
.....
Thanks
Louis
|
|
|
|
|
As far as I can tell from my experimentation with the accelerators functions, you need to do something like the following. In my example, the user would hold down Ctrl and a key they have assigned to the item.
you have the following member variables in your header file:
ACCEL* m_pAccel; //pointer to an array of ACCEL structs
HACCEL m_hAccel; //the actual accel table
int m_count; //number of accelerators
in your implementation file:
//your constructor
void MyListView :: MyListView ()
{
m_count = 20;
m_pAccel = new ACCEL[count];
}
//your handler for double click
void MyListView :: OnDblClk(....,....)
{
int index = HitTest(....,....);
...
// store hotkey information
pAccel[index].fVirt = FCONTROL|FVIRTKEY; //virtual keys work best imho
pAccel[index].key = VK_1; //the key
pAccel[index].cmd = IDM_FIRST_ROW; //a menu id
...
//unregister the hotkeys
::DestroyAcceleratorTable( hAccel );
//register the hotkeys
hAccel = ::CreateAcceleratorTable( pAccel, count );
}
//your handler for pre-translate message
BOOL MyListView :: PreTranslateMessage(MSG* pMsg)
{
::TranslateAccelerator( this->GetSafeHwnd(), hAccel, pMsg );
return CListView::PreTranslateMessage(pMsg);
}
Good luck.
Sef Tarbell
"A mind all logic is like a knife all blade, it makes the hand bleed that wields it." --Rabindranath Tagore
|
|
|
|
|
Thanks.
It all makes sense now.
Cheers.
Louis
|
|
|
|
|
Hello, I'm novice with VC++6 and I would like to know wich differences are between declaring a class, a function or a variable in a header or in a cpp file...
If I have to use a global var, where should I put it?
Thank you!
|
|
|
|
|
It's all about scoping.
If you make a declaration in a CPP file, then that declaration is only available in that file. So, for a global, it's not good.
If you declare in a header file, then you can include it multiple times (ie, once for each cpp file in your project)
If you want a global variable, you should declare it like this in one of your header files:
<font color=blue>extern</font> typename varname;
extern int nTurtles;
You then need the implementation of that variable. Put this in 1, and only one, cpp file:
typename varname;
int nTurtles;
It would be ok technically to declare a class in a cpp file, along with it's implementation. However, this is bad programming practise, and i'd personally avoid it.
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Jon's reply is spot on IMHO but maybe a bit of coding philosophy is in order. The distinction between .h and .cpp files is really all about information hiding. That's what he means by scope really. A .h file can be included pretty well anywhere so you can give access to the code it contains to pretty well anything you want just by using a #include. In other words what you really want in the .h file is the interface to whatever code it supports. A fundamental principle of software engineering is to minimise the interface. That means put as little as possible into the .h file and hide the rest in the .cpp file. To a large extent, users of your code only have to worry about what is in the .h file in this case. You're hiding the implementation details from the user (in this case I mean other programmers or you yourself in six months time when you've forgotten how your super duper widget class works).
People can get really stuffy and prissy about using globals and functions that aren't class members.
I find globals extremely useful sometimes. For example I nearly always have an instance of a CLog class that logs diagnostic data to disk from pretty well everywhere in everything I write. Making this a global means I don't have to worry about passing it around everywhere as a parameter. If you limit yourself to a few cases like this then I don't have a problem with globals.
Non-member functions are often recommended by the gurus. Stroustrup uses them a lot in 'The C++ Programming Language', I think (my copy is at work so can't check it was him), as helper functions. His argument is solid (if a bit too advanced for details here) but it seems to go against the grain of conventional wisdom that says make your functions members of the class on which they operate.
A good set of rules of thumb is only use globals where they really make life easier and implement them like Jon suggests, put your functions in a class as members of that class, and put your class interface in the .h file and it's implementation in the .cpp file. Like all rules these are made to be broken but knowing when you can break them safely only comes with pain and experience.
The point really is that you need to strive towards coding correctly but if you make a few wrong decisions along the way nobody's going to shoot you. There aren't many coders out there who can honestly look at code they wrote six months ago and not find something they would do differently now.
The good thing about C++ is you can write really really bad code and it will still work (generally speaking....). It's only when you come back to a big project a few months down the line that your inexperience will bite you in the ass. But then again, if you're working on a big project there should be plenty of people around to rip your code to bits for you so you don't make those mistakes in production code.
That's the biggest tip any newbie can get. Get your code reviewed. If you haven't got a guru handy then do it yourself against a book.
Anyway, end of sermon. Hope that helps and welcome to the mad house .
i1.2sqrt(u).bcos(ur)sec(c)
but
b4.isqrt(u).ru/16
|
|
|
|
|
I plan to buy Visual C# Standard Edition, but what have Visual C# Pro that Visual C# Standard doen't have?
Do you know in details so you can write down as much as you know !!
the price is not so important to me!
I give you for this if you can help!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
I don't know the difference,but if the price is not important(also I don't know the prices of them;)) why don't you buy newer version?In visual studio6 ,pro. version had more features.
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
ok Does the CTrayNotifyIcon class by P.J Naughter work for an mdi app cos I can't get it to go.
Anyone else got it to work (properly) or have you just used sdi apps like everyone else?
|
|
|
|
|
C'mon Chris surely you know about this having written a wrapper around this API.
|
|
|
|
|
Of course it does! The implementation is precisely no different at all.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
hi,
i tried playing a wave file by using PlaySound() function
#include "Mmsystem.h"
...
...
PlaySound("trumpet.wav",NULL,SND_FILENAME);
...
it gave the following error:
playDlg.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
Debug/play.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
i came to know that u need to add wavelib.lib file in
Project->settings->Link,which I rightly did.But then it says there is no wavelib.lib file in the folder.I tried to download the file from web but i could not find it.
Can anyone suggest where can I get the file or else can anyone say y it happens.
Thanx in advance
Kamal
pollachikk@yahoo.com
|
|
|
|
|
According my msdn it says to use winmm.lib declared in mmsystem.h
I did a local search for winlib.lib and didn't find anything
but i did find winmm.lib.
So here's my advice...try that and see what happens...
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
[removed]
modified 27-Nov-11 9:29am.
|
|
|
|
|
[removed]
modified 27-Nov-11 9:30am.
|
|
|
|
|
Ah, I see.
What people have done in the past is create a class whos member variable is the variable to be initialized at program start. Then just create one global instance of that class.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
DOH, stupid me. Create any class and create a global instance of it. Use that to perform any program start initializations.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Looks like a factory pattern is what you want.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|