|
Derive a control from CEdit, handle WM_PASTE, and do not call the base class in the override.
Do you want to generally disable the paste in the menu, or only if the editbox gets the focus ?
~RaGE();
|
|
|
|
|
thank you for the first solution
and i want only to disable pasting when the editbox got the focus.
just modified:
LRESULT CMyEdit::WindowProc(UINT message ...)
{
if ( message != WM_PASTE)
{
return ...
}
}
this works already great, i can not paste by using ctrl+v but the menuitem isn't disabled (but it alsoo doesn't work pasting (that was the intention))
so my problem is solved i guess
Thanksalot
greetings
Jens
|
|
|
|
|
|
dear all,
i want to create checkbox control at runtime and the number of controls can vary everytime the app runs.
i have to do this in either MFC or using win32 api.
is there any sample or links which shows the same.
my main concern is the positioning of the controls and the size of the main window.
any clues!!!!!!!!!
thanx and regards
|
|
|
|
|
|
Greetings. I have an VC++ 6.0 App, and i'm moving to .NET. But i've chosen VC#. My question is. Is it possible to call a VC# dll from the VC++ 6.0 App? If it is, how can i do it? Thank u.
|
|
|
|
|
What you can do is creating a typelib (.tlb) of the C# .dll with tlbexport.exe and access the C#-classes like COM-Objects from within C++.
Regards,
Andre
|
|
|
|
|
Hi!
I am porting a piece of code from a Dialog style program to a SDI one.
There is a GetFont in OnInitDialog, so I put the same GetFont in CView::OnInitialUpdate. But it return a NULL pointer.
It seems CView dont have a default font but dialog take one, isn't it?
|
|
|
|
|
novachen wrote:
It seems CView dont have a default font but dialog take one, isn't it?
Correct. It doesn't make much sense for a CView to have a default font, as what is displayed in the View is completely up to you. If you need GetFont() to work then you need to implement it and return whatever makes sense for your view.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hi everybody !
I have a dll that 'produces' some objects (through the use of a function). Something that looks like:
HRESULT __declspec( dllexport ) DllGetFactoryObject(CToolFactoryIntfce *& ppObject)
{
ppObject = (CToolFactoryIntfce*) new CToolFactory;
return NO_ERROR;
}
This object (the CToolFactoryIntfce) has his own Release method to destroy itself (delete this). So I when I call Release, the memory allocated by the dll is destroyed by the Dll. So, till now everything works perfectly.
Now, in this object, I have a method that returns a structure containing some data. The structure looks like:
struct TOOL_CONFIG_STRUCT
{
BYTE* pConfigData;
int ConfigSize;
void Clear()
{
pConfigData = NULL;
ConfigSize = 0;
}
void Release()
{
if (pConfigData)
{
delete[] pConfigData;
pConfigData = NULL;
}
delete this;
}
void SetData(void* pData, int Size)
{
if (pConfigData)
{
delete[] pConfigData;
pConfigData = NULL;
}
pConfigData = new BYTE[Size];
memcpy(pConfigData,pData,Size);
ConfigSize = Size;
}
};
The method from the CToolFactory object looks like:
virtual void GetData(TOOL_CONFIG_STRUCT** ppToolData)
{
*ppToolData = new TOOL_CONFIG_STRUCT;
(*ppToolData)->Clear();
(*ppToolData)->SetData(pData,nSize);
};
So, that's for the Dll part. Now, in my main application, I retrieve a CToolFatory object and I call the GetData member function:
TOOL_CONFIG_STRUCT* pNewData = NULL;<br />
pToolFactory->GetData(pNewData);
(pToolFactory is a CToolFactoryIntfce object obtained throug the DllGetFactoryObject function)
That works correctly also! But the problem come when I call the Release function:
pNewData->Release();
It says that the memory was not allocated from the same heap !!!!
Anybody has any idea of what's happening here ??
Thanks a lot
|
|
|
|
|
As TOOL_CONFIG_STRUCT::Release is inlineable, the client app does indeed inline it and thus uses its heap instead of that of the DLL. Declare this method as virtual and you're done.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot!! This works fine
|
|
|
|
|
HI,
I create an windows service in visual C++ 6.0. To install my service i use following command line :
MyService -install
I want to execute this command by program for exemple by a process or Shellexecute function. It's work well but the black command line window always display.
Is there any way to hide this window ?
Thanks in advance
Cheickna
|
|
|
|
|
If you wish to use ShellExecute
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
nShowCmd
If lpFile specifies an executable file, nShowCmd specifies how the application
is to be shown when it is opened. This parameter can be one of the following values:
SW_HIDE Hides the window and activates another window.
SW_MAXIMIZE Maximizes the specified window.
SW_MINIMIZE Minimizes the specified window and activates the next top-level
window in the z-order.
SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position.
An application should specify this flag when restoring a minimized window.
SW_SHOW Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified
in theSTARTUPINFO structure passed to theCreateProcess function by the
program that started the application. An application should callShowWindow
with this flag to set the initial show state of its main window.
SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window
remains active.
SW_SHOWNA Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and position.
The active window remains active.
SW_SHOWNORMAL Activates and displays a window.
If the window is minimized or maximized,
Windows restores it to its original size and position.
An application should specify this flag when displaying
the window for the first time.
|
|
|
|
|
I would like to know the way to get the size of physical disks (hard disks).
When I use IOCTL_DISK_GET_DRIVE_GEOMETRY, it tells me the size of \\.\physicaldisk0 is 33814126080 bytes = 32247 MB
But actually it is a Maxtor 57GB hard disk, also WIndows Disk Management Tool tells me the size is 55.91 GB.
Could anyone teach me a correct way to get the size of physical disks? Thanks.
BuggyMax
|
|
|
|
|
Does this help???
LPCTSTR lpDirectoryName; // directory name
ULARGE_INTEGER lpFreeBytesAvailable; // bytes available to caller
ULARGE_INTEGER lpTotalNumberOfBytes; // bytes on disk
ULARGE_INTEGER lpTotalNumberOfFreeBytes; // free bytes on disk
lpDirectoryName = "c:";
lpFreeBytesAvailable.QuadPart = 0;
lpTotalNumberOfBytes.QuadPart = 0;
lpTotalNumberOfFreeBytes.QuadPart = 0;
FARPROC pGetDiskFreeSpaceEx;
pGetDiskFreeSpaceEx = GetProcAddress( GetModuleHandle("kernel32.dll"),
"GetDiskFreeSpaceExA");
if (pGetDiskFreeSpaceEx)
{
GetDiskFreeSpaceEx (lpDirectoryName,
(PULARGE_INTEGER)&lpFreeBytesAvailable,
(PULARGE_INTEGER)&lpTotalNumberOfBytes,
(PULARGE_INTEGER)&lpTotalNumberOfFreeBytes);
}
else
{
AfxMessageBox(_T("Error"));
}
|
|
|
|
|
Xander80 wrote:
lpDirectoryName = "c:";
Thanks but "C:" is logical drive. What I need is size of physical disks.
Thanks.
BuggyMax
|
|
|
|
|
BuggyMax wrote:
physicaldisk0 is 33814126080 byte
How do you get that ?
You should multiply : bytes per sector * sectors per track * track per cylinder * cylinders to get your size.
If this does not work, maybe use IOCTL_DISK_GET_DRIVE_LAYOUT to get the partitions and IOCTL_DISK_GET_PARTITION_INFO to retrieve the sizes.
~RaGE();
|
|
|
|
|
Rage wrote:
You should multiply : bytes per sector * sectors per track * track per cylinder * cylinders to get your size.
Yes that huge number (33814126080) is the result of multiplying the four values.
Rage wrote:
If this does not work, maybe use IOCTL_DISK_GET_DRIVE_LAYOUT to get the partitions and IOCTL_DISK_GET_PARTITION_INFO to retrieve the sizes.
What if the disk contains NO partitions?
BuggyMax
|
|
|
|
|
This correctly reports that I have a (roughly) 13GB disk:
HANDLE disk;
DWORD dwNeeded;
DISK_GEOMETRY *geometry;
disk=CreateFile("\\\\.\\PHYSICALDRIVE0",
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (INVALID_HANDLE_VALUE != disk)
{
geometry = new DISK_GEOMETRY;
DeviceIoControl(disk,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
geometry,
sizeof(DISK_GEOMETRY),
&dwNeeded,
NULL);
TRACE(" Cylinders: %I64u\n", geometry->Cylinders);
TRACE(" Media Type: %d\n", geometry->MediaType);
TRACE("Tracks/Cylinder: %lu\n", geometry->TracksPerCylinder);
TRACE(" Sectors/Track: %lu\n", geometry->SectorsPerTrack);
TRACE(" Bytes/Sector: %lu\n", geometry->BytesPerSector);
delete [] geometry;
CloseHandle(disk);
}
|
|
|
|
|
That source code was also what I used. But the values I got were:
Cylinders: 4111 ( I use __int64 already.)
TracksPerCylinder: 255
SectorsPerTrack: 63
BytesPerSector: 512
The result, as you see, is 33GB.
But actually it is a 55.9GB one.
It means amount of cylinders should be 6964.
BuggyMax
|
|
|
|
|
I am showing bar Graph on a dilaog using progress bars. The graph is dynamically updating and this is shown by vayring values of progress bar.
I simply want the dialog to printed on a paper when the user clicks on a certain button on the dialog.
Plz guide me how to do so.
Reply me soon
|
|
|
|
|
I have developed a Dialog based Application.
I am using an ActiveX control. It plays a multimedia file.
Whenever it plays a file, it took a huge amount of memory, because the memory consumption depends on the number of frames contained in the file being played by the ActiveX control.
Now what I like, is to reclaim the memory consumed by the file.
Please can anybody tell me, how to reclaim the memory, because if we are reclaiming the memory it means we know in advance the location in memory we are consuming.
Please I need utmost help in this regard.
The Phantom. ™
|
|
|
|
|
Is your app allocating the memory, or is the ActiveX control doing it?
|
|
|
|
|
The ActiveX control consuming the memory...
The Phantom. ™
|
|
|
|