|
If you make your service a COM server (which the ATL Wizard can generate), you can then get your client program to interact with the service via COM. I have used this method when both the client and server apps reside on the same machine.
Michael
|
|
|
|
|
|
I use a prog on my own computer called AOL Instant Logger to log all of my AIM messages (not the AOL prog, the AIM prog, just to avoid confusion...). Anyway, does anyone know how one would write a program such as this? I'm not sure how to make one get the data from the AIM application. Any tips would be appreciated.
~Cam (BinaryUprising.com)
|
|
|
|
|
double& Matrix::operator() (unsigned row, unsigned col)
{
if (row >= rows_ ¦¦ col >= cols_)
throw BadIndex("Matrix subscript out of bounds");
return data_[cols_*row + col];
}
double Matrix::operator() (unsigned row, unsigned col) const
{
if (row >= rows_ ¦¦ col >= cols_)
throw BadIndex("const Matrix subscript out of bounds");
return data_[cols_*row + col];
}
what differnce double& and double?
why their implement is same?
can you tell me ?thank in indvance!
|
|
|
|
|
Passing by reference means that any changes to the variable in the function effect the variable that was passed into the function, just like a pointer. Unlike a pointer, a reference is a value, not a memory address.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Ooops - I just saw where the reference is. Yes, because this variable remains in scope, it means that the variable you get back IS the variable in the array, not just the value of that variable.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
The difference is that the first version has a non-const this pointer, so the returned value is a reference to an array value. That means you can change the contents of the Matrix, such as:
void f ( Matrix& m )
{
m(2,5) = 3.14;
} But in the second, this is const, thus the return value cannot reference the object. So this code is illegal:
void g ( const Matrix& m )
{
m(4,1) = 42;
}
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
One function accepts an address of another as a parameter, I want to use a member-function of a class as the parameter, but I have this error: cannot convert parameter 1 from 'void (void)' to 'int (__cdecl *)(void)'
There's an example (MVSC++6) (Compilation gives the error)
typedef void(*fntFunc)();
class CMy
{
public:
CMy(){};
~CMy(){};
void Func();
};
void CMy::Func(){}
void CallIt(fntFunc fn)
{
fn();
}
int main(int argc, char* argv[])
{
CMy my;
CallIt(my.Func);
}
Thanks a lot. http://sjcomp.virtualave.net
|
|
|
|
|
Two issues here:- Your
Func method has to be static if you want to pass it on as a regular function pointer. Check Mike Dunn's C++ FAQ for details.
- Once you hace declared your method static, you can set its calling convention like this:
class CMy{
...
static void __cdecl Func();
};
Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín is right.
A standard solution to this common problem is to have 2 static items: (1) a pointer to a CMy object and (2) a function of the type you expect to pass as a parameter, eg:
static CMy* pMy = NULL;
static void StaticFunc()
{
if (pMy != NULL) {
pMy->Func();
}
} Then, have a CMy object set the static pMy to "this" before you pass StaticFunc() to CallIt(), eg:
CMy my;
pMy = &my;
CallIt (&StaticFunc);
Hope this helps.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
I'm probably stating the obvious here, but my solution is slightly different from Joaquin's in that CMy's member function doesn't have to be static.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
|
Thanks everyone for assistance, it solves the problem as I state it, but the situation I have is like this: I have a function which is predefined and this function takes a callback function as parameter. I'm creating class, each copy of which should have it's own call back function. (I'm using glut (for OpenGL) and I'm creating window class whcih uses glut functions, and I'd like glut call a member-function of the class.)
Let's say I have function
void CallIt( void(*func)(ini,int)) );
And I can not change it.
The problem is that I want to have a couple of classes which are waiting for the callback, and CallIt doesn't provide inforamtion what class set the callback (
And as understood I can use only static functions or global functions and I can use class specific functions to link with CallIt.
I dont' see a way to do it, right now, but hope I'm wrong.
Regards, Alexander.
|
|
|
|
|
Well, the standard solution is to provide a pointer to the class when you register your function (this is usually called a callback parameter): this callback parameter can be used by your static callback function to transfer the function call to the actual class responsible for doing the job.
Unfortunately, GLUT seems not to provide any mechanism to store any callback parameter on callback registration. But do not abandon any hope, there's still a way (if a little convoluted) to retrieve the class, via glutGetWindow() . The idea is having a map associating windows IDs with classes, and having the static method dispatch to the appropriate class using this map. This is s little piece of pseudocode that describes the process using the glutMouseFunc callback:
class MyGlutWindow{
private:
static std::map<int,MyGlutWindow*> ID2MyGlutWindow;
public:
MyGlutWindow(){
...
ID2MyGlutWindow[glutGetWindow()]=this;
}
static void __cdecl glutMouseFuncCallback(int button,int state,int x, int y){
ID2MyGlutWindow[glutGetWindow()]->doGlutMouseFuncCallback(button,state,x,y);
}
void doGlutMouseFuncCallback(int button,int state,int x, int y){
...
}
}; There are some details missing (cleanup when windows are destroyed, for instance), but the basics are here, I hope you get the idea and find it useful.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot! It really helps Have not thought about such aproach. Thanks.
Regards, Alexander
|
|
|
|
|
Well I'm no Delphi expert, but I guess the best thing to do is having the array allocated (even statically) on the Delphi client. Just like this:
var
myarray packed array [1..801] of char;
...
begin
...
TheDLLFuntion(...,@(myarray[1]),...);
...
end; where TheDLLFunction accepts a char * (a ^char in Delphi).
As I said before, I'm no expert in Delphi, so forgive me if this is off-topic (or simply incorrect).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
PS: Has anybody had problems trying to reply other posts? For some reason I'm not being able and have been forced to post the reply on a new thread.
|
|
|
|
|
Are there API functions available to access a USB port? Just as we have CreateFile() for the serial port?
|
|
|
|
|
I wonder how to check an item in a menu?
(this code in OnInitDialog())
CMenu menu;
menu.LoadMenu(IDR_POPUP);
menu.CheckMenuItem(ID_POPUP_ALLTIDVERST,MF_CHECKED | MF_BYCOMMAND);
Isn't the the menu allready created from start?
Or do I have to overriden some function?
It wont be selected?
The menu is a tray menu...
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
This menu is being created and then destroyed right away. To check or uncheck an item, you need to use the OnCmdUI handler, or you need to check it in OnContextMenu, just before you show it.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
If you're not using ON_COMMAND_UI handlers (i.e: if you have a standalone menu or are building a dialog based app), you can use CMenu::ModifyMenu() to check/disable/gray a menu item.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
My function (in my DLL-VC) have to return to the Delphi client program a array of 801 characters . BYTE arr[801]
that 801 can include everyone from the characters that exist and even NULL s
since Delphi have not type BYTE* or CString
The problem:
If my function gets char* and try to write into,
it gives error "access invalidation..." at Delphi
If the function returns char* ,
the Delphi program don't know where the string terminate because that string can contain some NULLs that confuses the program.
How it possible that the function vc++ could to give array of characters at constant length (as 801 bytes) for Delphi program ???
|
|
|
|
|
in my Document class the function serialize... I wan,t to save my data as a monochrome bitmap so I do
void CWoopDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
CBitmap BitMapTemp;
CDC CBitmapDC;
CBitmap* OldBitMap;
CBitmapDC.CreateCompatibleDC(NULL);
void * bitmapbitstemp = malloc( Size_X*Size_Y / sizeof(BYTE));
BitMapTemp.CreateBitmap(Size_X,Size_Y,1,1,bitmapbitstemp);
OldBitMap = CBitmapDC.SelectObject(&BitMapTemp);
BITMAPFILEHEADER BmpFileH;
BITMAPINFOHEADER bmpInfoH;
BITMAP bm;
BitMapTemp.GetBitmap(&bm);
BmpFileH.biBitCount = bm.bmBitsPixel;
BmpFileH.biCompression = BI_RGB;
BmpFileH.biHeight = bm.bmHeight;
BmpFileH.biPlanes = bm.bmPlanes;
BmpFileH.biWidth = bm.bmWidth;
BmpFileH.biSizeImage = BI_RGB;
BmpFileH.biClrUsed = 0;
BmpFileH.biClrImportant = 2;
BmpFileH.biXPelsPerMeter = 0;
BmpFileH.biYPelsPerMeter = 0;
BmpFileH.biSize = sizeof(BmpFileH);
bmpInfoH.bfOffBits = sizeof(bmpInfoH)+sizeof(BmpFileH);
bmpInfoH.bfSize = bm.bmWidthBytes;
bmpInfoH.bfType = ('M' << 8 | 'B');
bmpInfoH.bfReserved1 = 0;
bmpInfoH.bfReserved2 = 0;
ar.Write(&BmpFileH,sizeof(BmpFileH));
ar.Write(&bmpInfoH,sizeof(bmpInfoH));
ar.Write(bm.bmBits,bm.bmWidthBytes);
CBitmapDC.SelectObject(OldBitMap);
delete bitmapbitstemp;
}
else
{
}
}
BitMapTemp.Serialize(ar); //do not work...
any help will be fine...
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
Are you sure you're drawing in the correct map? Using CBitMapDC->LineTo etc?
It sounds as if there is nothing in BitMapTemp.
Hope this helps,
Bill
|
|
|
|
|
Hi, all, I have problem doing a replacement of text in my text editor using
CRichEditView class. I want to replace some text that the user types but
have no idea what functions I can use. I am aware of the
GetRichEditCtrl( ).Paste, which can paste a copied text at the position of
the caret, but how do I insert a not clipboard stuff, such as a CString
object.
Peace, no war
|
|
|
|
|
Hi, all, I'm programming a text editor with spell check using MFC's
CRichEditView class. Anybody knows how to move the caret?
My usage is that when the user types a word that is found spelled wrong, the
editor has to move its caret to the word's beginning position and replace
the word. I'm new to Windows programming. I have no idea how to move the
caret and replace the word. I tried typing SetCaretPos( ) and ShowCaret( )
in the CMainFrame derived from CFrameWnd, but it didn't actually move the
caret. The caret seemed to change its postion to the one I set in
SetCaretPos( ), but when I used GetRichEditCtrl( ).Paste to paste a text for
a test, the text was pasted at the position as if I didn't do the
SetCaretPos( ).
Peace, no war
|
|
|
|