|
DirectShow API
PlaySound() function for wav sounds
MCI for midi...
NG
|
|
|
|
|
Respected all
I want to capture the bitmap(the client area of window on which bitmap is residing) which is dispaying when i executed my program and store it in temorary storage as "abc.bmp"(let say).
and then take print of abc.bmp.
Plz help me.very urgent needed.
Thanking u people
david
|
|
|
|
|
you can find here on codeproject
1: Window Capture
2: DDB to DIB
3: SaveDibToFile()
4: Create a printerDC
5: Bitblt the bitmap on the dc
6: EndDocument() --- print
that are the steps...
NG
|
|
|
|
|
Hi,
I use DrawFocusRect to draw the focus rectangle of a owner drawn button. I need to change the color of focus rectangle. How can I do it?
Thanks.
- NS -
|
|
|
|
|
Change the system colors. See ::SetSysColors . The color of the focus rectangle surely is one of the system colors.
--
The Blog: Bits and Pieces
|
|
|
|
|
Sorry, that is not applicable.
Because I use a owner draw button. I only need to change it only. If I change the system color, it will also affect the buttons that do not have owner draw style (I think so!).
Is there any other methods?
- NS -
|
|
|
|
|
Nishad S wrote:
If I change the system color, it will also affect the buttons that do not have owner draw style
Of course. But ::DrawFocusRect is a Win32 API, and as such it'll use the system colors (I don't bet on it - it might just XOR black with the HDC pixels). So, if it doesn't do what you want, don't use it.
Nishad S wrote:
Is there any other methods?
Draw the rectangle yourself, of course.
--
The Blog: Bits and Pieces
-- modified at 4:33 Wednesday 21st September, 2005
|
|
|
|
|
Thank you.
I tried it. But the built in pen styles do not match focus rect line (dotted line).
And creating a user style pen is a complex one, isn't it?
Can you explain the neccessary steps to create a pen just for drawing dotted lines (for focus rectangle)?
- NS -
|
|
|
|
|
Nishad S wrote:
create a pen just for drawing dotted lines
Literate programming:
::CreatePen(PS_DOT, 1, color);
--
The Blog: Bits and Pieces
|
|
|
|
|
Sorry, the result is not exactly as the DrawFocusRect do.
I did the following...
CPen pen(PS_DOT, 1, RGB(255,128,0));
CPen* pOldPen = dc.SelectObject(&pen);
dc.Rectangle(&rt);
The dots are little longer!!!
- NS -
|
|
|
|
|
hi all
i want to load a bitmap from a dll.
i did these:
0- loadlibrary
1- findresource
2- loadresource
3- lockresource
in the last step i get a LPVOID (according to MSDN it is a pointer to the first bit of the resource. i don know what to do after that and how to display it. . does anyone know how should i get this LPVOID to a CBitmap to view it??
oh, am i doing the right thing to load a resource from a dll??
|
|
|
|
|
If it's really a bitmap (BMP), then use ::LoadBitmap or ::LoadImage instead. They do all the other stuff plus more internally for you. If it's a raw RGB stream you have as a resource, then plug that void* into ::CreateDIBSection or ::CreateDIBitmap .
--
The Blog: Bits and Pieces
-- modified at 1:35 Wednesday 21st September, 2005
|
|
|
|
|
I really need some example and guide about how to program a sending data under mewtocol command messasge using TCP/IP. Can someone help me.
|
|
|
|
|
Does anyone know how to get the private memory usage of my program (e.g. "Private Bytes" in the Performance tool).
Thanks!
|
|
|
|
|
Find your 'process' by name, and then under items to add select the Private Bytes to the graph.
|
|
|
|
|
Sorry, should've been more specific. I want to be able to do that from within my program. I hunted around the various APIs, but I couldn't find anything.
|
|
|
|
|
|
Create an instance of CMemChecker.
Call CMemChecker.ScanMemory();
Examine CMemChecker.m_BytesPrivate
It will be as close or more accurate than the other tool.
If you want how much is used by the DLL and other executable images, then look at
CMemChecker.m_BytesImage
If you want to know how much 'memory' is being used, then look at
CMemChecker.m_BytesCommit
If you want to know how much of your virtual address space has been consumed, then look at total of CMemChecker.m_BytesCommit + CMemChecker.m_BytesReserved
<br />
<br />
<br />
#pragma once<br />
<br />
class CMemChecker<br />
{<br />
public:<br />
<br />
CMemChecker();<br />
virtual ~CMemChecker();<br />
<br />
BOOL ScanMemory(void);<br />
<br />
virtual void ResetData(void);<br />
<br />
<br />
DWORD m_BytesCommit;<br />
DWORD m_RegionCountCommit;<br />
<br />
DWORD m_BytesFree;<br />
DWORD m_RegionCountFree;<br />
<br />
DWORD m_BytesReserved;<br />
DWORD m_RegionCountReserved;<br />
<br />
<br />
DWORD m_BytesImage;<br />
DWORD m_RegionCountImage;<br />
<br />
DWORD m_BytesMapped;<br />
DWORD m_RegionCountMapped;<br />
<br />
DWORD m_BytesPrivate;<br />
DWORD m_RegionCountPrivate;<br />
<br />
<br />
DWORD m_BytesOrphaned;<br />
DWORD m_RegionCountOrphaned;<br />
<br />
DWORD m_BytesAvailable;<br />
DWORD m_RegionCountAvailable;<br />
<br />
DWORD m_RegionCountTotal;<br />
<br />
DWORD m_MaxFreeBlock;<br />
DWORD m_MinFreeBlock;<br />
<br />
protected:<br />
<br />
SYSTEM_INFO m_SystemInfo;<br />
<br />
virtual void AccumulateData (PMEMORY_BASIC_INFORMATION lpMemInfo);<br />
virtual bool IsRegionOrphaned(PMEMORY_BASIC_INFORMATION lpMemInfo) const;<br />
<br />
};<br />
<br />
<br />
<br />
<br />
#include "stdafx.h"<br />
#include "limits.h"<br />
#include "CMemChecker.h"<br />
<br />
CMemChecker::CMemChecker()<br />
{<br />
ResetData();<br />
}<br />
<br />
CMemChecker::~CMemChecker()<br />
{<br />
}<br />
<br />
<br />
void CMemChecker::ResetData(void)<br />
{<br />
::GetSystemInfo(&m_SystemInfo);<br />
<br />
m_RegionCountTotal = 0;<br />
<br />
m_BytesCommit = 0;<br />
m_RegionCountCommit = 0;<br />
<br />
m_BytesFree = 0;<br />
m_RegionCountFree = 0;<br />
<br />
m_BytesReserved = 0;<br />
m_RegionCountReserved = 0;<br />
<br />
m_BytesImage = 0;<br />
m_RegionCountImage = 0;<br />
<br />
m_BytesMapped = 0;<br />
m_RegionCountMapped = 0;<br />
<br />
m_BytesPrivate = 0;<br />
m_RegionCountPrivate = 0;<br />
<br />
m_BytesOrphaned = 0;<br />
m_RegionCountOrphaned = 0;<br />
<br />
m_BytesAvailable = 0;<br />
m_RegionCountAvailable = 0;<br />
<br />
m_MaxFreeBlock = 0;<br />
m_MinFreeBlock = ULONG_MAX;<br />
}<br />
<br />
<br />
BOOL CMemChecker::ScanMemory(void)<br />
{<br />
BOOL bSuccess = TRUE;<br />
SIZE_T BytesRead;<br />
<br />
MEMORY_BASIC_INFORMATION TheBuffer;<br />
<br />
ResetData();<br />
<br />
LPVOID lpAddress = (LPVOID)m_SystemInfo.lpMinimumApplicationAddress;<br />
<br />
while( lpAddress < m_SystemInfo.lpMaximumApplicationAddress ){<br />
<br />
BytesRead = ::VirtualQuery(lpAddress, &TheBuffer, sizeof(TheBuffer));<br />
<br />
if( BytesRead < sizeof(TheBuffer) ){<br />
break;<br />
} else {<br />
AccumulateData(&TheBuffer);<br />
lpAddress = (LPVOID)((DWORD)TheBuffer.BaseAddress + (DWORD)TheBuffer.RegionSize);<br />
}<br />
}<br />
<br />
return bSuccess;<br />
}<br />
<br />
<br />
void CMemChecker::AccumulateData(<br />
PMEMORY_BASIC_INFORMATION lpMemInfo<br />
){<br />
m_RegionCountTotal++;<br />
<br />
switch( lpMemInfo->State ){<br />
<br />
case MEM_COMMIT:<br />
m_BytesCommit += lpMemInfo->RegionSize;<br />
m_RegionCountCommit++;<br />
break;<br />
<br />
case MEM_FREE:<br />
m_BytesFree += lpMemInfo->RegionSize;<br />
m_RegionCountFree++;<br />
<br />
if( m_MaxFreeBlock < lpMemInfo->RegionSize ){<br />
m_MaxFreeBlock = lpMemInfo->RegionSize;<br />
}<br />
<br />
if( m_MinFreeBlock > lpMemInfo->RegionSize ){<br />
m_MinFreeBlock = lpMemInfo->RegionSize;<br />
}<br />
<br />
if( IsRegionOrphaned(lpMemInfo) ){<br />
<br />
m_BytesOrphaned += lpMemInfo->RegionSize;<br />
m_RegionCountOrphaned++;<br />
<br />
} else {<br />
<br />
m_BytesAvailable += lpMemInfo->RegionSize;<br />
m_RegionCountAvailable++;<br />
}<br />
<br />
break;<br />
<br />
case MEM_RESERVE:<br />
m_BytesReserved += lpMemInfo->RegionSize;<br />
m_RegionCountReserved++;<br />
break;<br />
<br />
}<br />
<br />
switch( lpMemInfo->Type ){<br />
<br />
case MEM_IMAGE:<br />
m_BytesImage += lpMemInfo->RegionSize;<br />
m_RegionCountImage++;<br />
break;<br />
<br />
case MEM_MAPPED:<br />
m_BytesMapped += lpMemInfo->RegionSize;<br />
m_RegionCountMapped++;<br />
break;<br />
<br />
case MEM_PRIVATE:<br />
m_BytesPrivate += lpMemInfo->RegionSize;<br />
m_RegionCountPrivate++;<br />
break;<br />
<br />
}<br />
}<br />
<br />
bool CMemChecker::IsRegionOrphaned(<br />
PMEMORY_BASIC_INFORMATION lpMemInfo<br />
) const {<br />
return false;<br />
}<br />
<br />
<br />
<br />
|
|
|
|
|
I have a mewtocol command message format which have header(%or<),unit no. of destination,command code(#), command name (e.g.read contact), target that reads the value, check code(BCC), and terminator(Cr). I want to ask that when I send a data, it will send the header, unit of destination, command code and etc or it will send whole format to the receiver? I need to write a program that can send the data like what I have mention above. Can someone give some example or guide how to write the program. I only have a program that can send message just like msn. I don't have any idea how to send data like I mention above. Can help me......
|
|
|
|
|
jyhguang wrote:
I need to write a program that can send the data like what I have mention above
It would help if someone (here) understood what you mentioned above.
Before a receiver can know what it's expected to receive, it has to be told what to expect (or request the data itself). I assume that the destination command code(#) indicates the data type expected. In that case you should already have what you need.
Just wondering, how many peaple here did you expect to know about: mewtocal OPC servers and PLCs?
INTP
Every thing is relative...
|
|
|
|
|
I have a MFC Application with ToolBars etc.
I want to create a Modeless Dialog Box, but I do not the user to be able to click any buttons in the Main Application while this Dlg Box is displayed. Is there a way to do this, or do I have to use a Modal Dlg Box. The problem is if I have to use a Modal Dlg Box then I will have to spawn a separate thread to do this as I have to do some background processing.
Thanks for your help.
|
|
|
|
|
You basically want a modal dialog box, so why not create one ? I don't see how being modal or modeless changes the need for a background thread, assuming you need one at all.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
So disable the main application window before you show the dialog.
A bit of advice - it sounds like you're trying to do some sort of progress / wait dialog. That's fine - this is a good way to go about that. But keep in mind, if you're doing some sort of lengthy processing in your primary (UI) thread, the interface won't respond or repaint while that's happening anyway, since messages won't get pumped.
If you have something that is gonna take a while, see if you can't just spin off a separate thread to handle it, posting back status messages or whatever to the main thread. Trust me, it's a lot easier to plan it out and do it right the first time than it is to go back and hack around laziness later...
|
|
|
|
|
I am debugging a Visual C++ program, and my job is to speed up the file access. Currently the program is reading in a 600 MB ascii-text file using fopen and fscanf, etc., in text mode. Is there an easy way to speed this up? I have tried using streams and they aren't defined. Would changing it to binary make it faster?
Thanks so much for your help!
Jennifer
|
|
|
|
|
JenniferLeonard522 wrote:
I have tried using streams and they aren't defined.
How do you mean, they aren't defined ? Regardless of speed issues, moving your file handling code to c++ is a positive step.
Christian Graus - Microsoft MVP - C++
|
|
|
|