|
Arrgh... This time you were faster.
I vote pro drink
|
|
|
|
|
Arrgh... This time you were faster.
the pretty formatting notwithstanding
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Gregor S. wrote:
fprintf( outfile, "%d.%d.%d.%d:%hu\n", (ipaddr>>24)&0xff, (ipaddr>>16)&0xff, (ipaddr>>8)&0xff, ipaddr&0xff, port);
This will split your 4-byte number ipaddr into individual bytes and print them.
I vote pro drink
|
|
|
|
|
Thanks for your example.
I finally understand most of this memory manipulation stuff now.
11111111 11111111 11111111 11111111
11000000 10101000 00000000 00000001
<<24:
[00000000 00000000 00000000] 11000000
<<16:
[00000000 00000000 00000000] 10101000
<<8:
[00000000 00000000 00000000] 00000000
<<0 (not shifted):
[00000000 00000000 00000000] 00000001
To get keywords to appear in red, enclose them in <span style="color:red"> and </span>
|
|
|
|
|
Hello,
Can anyone tell me why I get this error?
error:
error C2243: 'static_cast' : conversion from 'class IStopwatch *' to 'struct IUnknown *' exists, but is inaccessible
Here is the code:
<pre>
HRESULT __stdcall CStopwatch::QueryInterface(REFIID riid, void **ppvObject)
{
HRESULT hr = S_OK;
if(riid == IID_IUnknown)
*ppvObject = static_cast<IUnknown*>(static_cast<IStopwatch*>(this)); <-- error
else if (riid == IID_IStopwatch)
*ppvObject = static_cast<IStopwatch*>(this);
else
{
ppvObject = NULL;
hr = E_NOINTERFACE;
}
if(SUCCEEDED(hr))
(static_cast<IUnknown*>(*ppvObject))->AddRef();
return hr;
}
</pre>
Here is my header:
<pre>
#if !defined(AFX_STOPWATCH_H__CF2EC9CF_CCAA_4708_8320_0B5A054E3876__INCLUDED_)
#define AFX_STOPWATCH_H__CF2EC9CF_CCAA_4708_8320_0B5A054E3876__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <windows.h>
class IStopwatch : IUnknown
{
public:
//IStopwatch specific functions
virtual HRESULT __stdcall Start() = 0;
virtual HRESULT __stdcall ElapsedTime(float *Time) = 0;
};
class CStopwatch : public IStopwatch
{
public:
CStopwatch();
virtual ~CStopwatch();
private:
// The frequency of the counter
// returned by QueryPerformanceCounter()
LARGE_INTEGER m_nFrequency;
// The counter value when the start method was last called.
LARGE_INTEGER m_nStartTime;
public:
// IUnknown methods
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject);
unsigned long __stdcall AddRef();
unsigned long __stdcall Release();
// IStopwatch specific functions
HRESULT __stdcall Start();
HRESULT __stdcall ElapsedTime(float *Time);
};
#endif // !defined(AFX_STOPWATCH_H__CF2EC9CF_CCAA_4708_8320_0B5A054E3876__INCLUDED_)
</pre>
Thanks,
Rob
|
|
|
|
|
IStopwatch inherits as private from IUnknown. Inherit public from IUnknown ( IStopwatch : public IUnknown )
|
|
|
|
|
Thanks! dumb mistake
Rob
|
|
|
|
|
How to PostMessage "NM_DBLCLK" to a Clistctrl ?
Thanx
|
|
|
|
|
Notification messages are sent by controls to their parent window. To simulate a double-click (I assume that's what you want to do), you should post a WM_LBUTTONDBLCLK message to the list control.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
A small example will be great..
|
|
|
|
|
To send a message use
// see help of PostMessage for parameter options
#define WM_GENNIE_LEARN_MODE 2000 // use any id as you desire
PostMessage(WM_GENNIE_LEARN_MODE);
Now in the message map of the class where you want the message to be captured (namely the parent class in your case) make an entry in the BEGIN_MESSAGE_MAP section as given below
IMPLEMENT_DYNCREATE(..., ...)
BEGIN_MESSAGE_MAP(... , ...)
//{{AFX_MSG_MAP(CDict1View)
ON_MESSAGE(WM_GENNIE_LEARN_MODE,OnGennieLearnMode)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Now declare the handler function, as given below
//{{AFX_MSG(CDict1View)
afx_msg LRESULT OnGennieLearnMode(WPARAM wParam, LPARAM lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
and define it as
LRESULT YourParentClassName::OnGennieLearnMode(WPARAM wParam, LPARAM lParam)
{
// blah blah blah ...
return ...;
}
/**********************/
The above code will send a message WM_GENNIE_LEARN_MODE to the parent window where it would be handled by the function OnGennieLearnMode(). In your case you would sen the DBLCLICK message, and handle it in your own handler function.
hope it helps,
-cheers
-kashif manzoor
peace to all
|
|
|
|
|
|
Hi All,
I wonder if any of you guys can help - and I certainly need some now!! For our software, I have written a grid control that looks like the MS Outlook grid control. However, in this release of the software I have been asked to add Outlook style grouping. I am finding the task harder than I thought and am now very worried about the looming deadline.
Does anyone know of any code for grouping data (each row in the grid is a safearray of variants). Given certain grouping criteria (i.e. group by column 2, then by 3), I need to get the data into a suitable datatype and then render it on the screen. Once data is in the datatype, I need to be able to iterate through it. I would be very, very grateful if anyone could point me to any example code of doing this or something similar to this.
Thanks,
Mike.
|
|
|
|
|
Check ATL part in CP,there are some example about grid,safearray and ...
Click here
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I am having a problem with the File menu's Open command. When I run my application and select Open from the File menu after performing some other action within the application or if I select Open from the File menu immediately upon entering the application, the Open file dialog opens fine. On the other hand, if I select Open from the File menu, click the "Cancel" button in the dialog, and then select Open again from the File menu, the application shuts down in debug mode and it inserts junk data into the "File Name" textbox in Release mode.
I'm not sure what I'm doing wrong since I haven't modified any of the code that the Application Wizard creates for you when you set up a new project. I'm not sure how the junk data is getting into the application or why. Does anyone have any thoughts?
|
|
|
|
|
If you are sure you havent touched the app-wizard generated code and yet this happens, then its time to either reinstall VC++ or probably your OS itself.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
I'm running it on a brand new computer that I got 3 weeks ago and I installed VC++ then. Unfortunately, I don't think it has anything to do with the OS or the installation of VC++.
|
|
|
|
|
Hi,
I need to run Ms Word automated, and my idea is to add some buttons to insert the Word Doc. some controls that has some reports thing, ... I will need to insert them ( maybe just a metafile, with some little info to know some settings).
Then I would need to insert the activeX in the word doc, and set the data ( metafile, and some properties).
And I would need to iterate through the activeX controls ( or detect the focus of the ActiveX file), and retrieve some properties from it ( take it from the word instance to my current program).
Is that possible ? ( the main problem that I see, is that the ActiveX DLL is running in a different proccess than the Main Application) Thanks, Bye !
Braulio
|
|
|
|
|
Hi guys,
This is my first post in code project. I am new to Win32 Application development. I have written the following code to check for CDROM drive on computer. THe code seems alright but when I compile it, I get the following error
error C2065: 'sprintf' : undeclared identifier
I have included stdio.h but still I cannot resolve the problem. Hope someone helps me. thanks
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include "stdafx.h"
int test;
UINT retval;
LPCTSTR chTest;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char ascii;
char ascTemp[80];
ascii = 'A';
while (ascii <= 'Z') {
test = sprintf(ascTemp,"%c:\\",ascii);
if (GetDriveType(ascTemp)== 1)
{
test = MessageBoxEx(NULL,"Found","ABC",NULL, NULL);
}
ascii = ascii + 1;
}
return 0;
}
|
|
|
|
|
tppradeep18 wrote:
I have included stidio.h but still I cannot resolve the problem. Hope someone helps me. thanks
Did you mean to type stdio.h ? I can't tell because you've not shown the headers, you need to check the box that says not to use HTML, your includes have been stripped because they look like tags. If you have included stdio.h, then I dunno why it's not working.
In this case sprintf is obviously OK, but overall I prefer to use ostringstream for safety.
ascii += 1 is preferred as a matter of efficiency, you save the creation of a tempory.
It's a good idea to specify global scope with the :: operator, like this ::MessageBox(etc
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
thanks graus for that instant reply.
I have editied my question. I liked the tips given by you for increasing the efficiency. I am still caught up with the error. Any more clues as to why this is happening.
|
|
|
|
|
include "stdafx.h" before including anything else i.e. move #include "stdafx.h" statement to the top and you won't get the error message
-cheers
-kashif manzoor
peace to all
|
|
|
|
|
thanks kashif. It worked. My problem is solved. thanks a lot !!!
|
|
|
|
|
#include < windows.h >
#include < tchar.h >
#include < stdio.h >
<font color=green>#define SIZE 80</font>
int test;
UINT retval;
LPCTSTR chTest;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char ascii;
char ascTemp[SIZE];
ascii = 'A';
while (ascii <= 'Z') {
<font color=green>test = _snprintf(ascTemp,SIZE,"%c:\\",ascii); </font>
if (GetDriveType(ascTemp)== DRIVE_CDROM)
{
<font color=green>_snprintf(ascTemp,SIZE,"Found CDROM %c:\\",ascii);</font>
test = MessageBoxEx(NULL, ascTemp, "CDROM Drive", MB_OK, 0);
}
++ascii;
}
return 0;
}
It works..try it. Use _snprintf instead of sprintf for bounds safety.
Atul
Sonork ID : 100.13714 netdiva
|
|
|
|
|
Hi. I am having a tough time finding a way to tell if a printer is actually connected to a computer. By knowing this, I can save it to disk instead of printing it etc. Does anyone know a good way to find out if a printer is actually connected?
|
|
|
|