|
toxcct wrote: 34 bytes on a 64 bits system
Two bytes wide!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
what ?
hey, not 34, 32 !! lol
|
|
|
|
|
Ive gone quite crazy at microsoft for the weirdness of the CListCtrl, I just want to find out the contents of the selection in my list.. I can only find this:
short Selected = m_MyList.GetSelectionMark();
But that returns the number of the item, if i fill my list with "Linux" and "Windows" then i would like a method which returns "Windows", or "Linux"... Are there any functions for that??
Thanks!
(Using VS6.0 dialog based mfc app...)
//Johannes
|
|
|
|
|
Try:
CString sText;
int nSel;
nSel = m_MyList.GetSelectionMark();
if (sel != -1)
{
sText = m_MyList.GetItemText(nSel, 0);
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
|
Can't you check if actual item is different of first / last item before moving?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Johpoke wrote: short Selected = m_MyList.GetSelectionMark();
Are you using a multiselect list control?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How to know when the dragging is completed?
|
|
|
|
|
|
i have a CCD camera that acquires 12 bit image and i have used MFC function BitMapInfoheader function to save it as 8 bit as a result my image displayed is compressed and i loose finer details could u please help to correct my code for 16 bit the code is as below.
Thank you in advance
./* Window.C */
#include "stdafx.h"
#include "afxstr.h"
#include "atlimage.h"
#include "string.h"
extern "C"
{
#include
#include "wingdi.h"
#include "win.h"
#include "master.h"
}
#define ALIGNLONG(i) ((i+3)/4*4)
#define COLORBITS 8
CImage image;
void Draw_Strip( HWND hWnd );
HBRUSH ghbrWhite, ghbrBlack;
void Create_DIB( HWND wnd );
void Draw_DIB( HWND wnd );
/*
* Some handy globals.
*/
CString fullname;
int W, H;
unsigned int Min,Max;
static HBITMAP hBitmap;
static LPBITMAPINFOHEADER lpbi;
static BITMAPINFOHEADER bi;
char *lpstBitmap;
HPALETTE palette;
CString name = "Image";
//CImage image;
/**************************************************
*
* Register this type of window...
*
*
**************************************************/
BOOL RegisterWindow(char *lpClass, HINSTANCE instance)
{
WNDCLASS wc;
ghbrWhite = CreateSolidBrush(0x00FFFFFF);
ghbrBlack = CreateSolidBrush(0x00000000);
wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) ImageWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(LONG);
wc.hInstance = instance;
wc.hIcon = LoadIcon(NULL,IDC_ARROW);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = ghbrWhite;
wc.lpszMenuName = NULL;
wc.lpszClassName = lpClass;
if (!RegisterClass(&wc))
return FALSE;
else
return TRUE;
}
/**************************************************
*
* Create and show the window....
*
*
**************************************************/
HWND CreateWin( int x,
int y,
int width,
int height,
char *lpClass,
char *name,
HINSTANCE instance)
{
HWND handle;
W = width;
H = height;
handle = CreateWindow(
lpClass, // pointer to registered class name
name, // pointer to window name
WS_VISIBLE | WS_OVERLAPPEDWINDOW, //| WS_VSCROLL | WS_HSCROLL, // window style
x, // horizontal position of window
y+20, // vertical position of window
width, // window width
height, // window height
NULL, // handle to parent or owner window
NULL, // handle to menu or child-window identifier
instance, // handle to application instance
NULL // pointer to window-creation data
);
return (handle);
}
/**************************************************
*
* Handles the messages for this window
*
*
**************************************************/
int WINAPI ImageWndProc(
HWND hwnd,
UINT message,
DWORD wParam,
LONG lParam)
{
switch (message)
{
case WM_PAINT:
Draw_DIB( hwnd );
return 0L;
break;
case WM_SIZE:
return DefMDIChildProc(hwnd, message, wParam, lParam);
break;
case WM_CREATE:
Create_DIB( hwnd );
return 0L;
break;
case WM_CLOSE:
return DefMDIChildProc(hwnd, message, wParam, lParam);
break;
case WM_DESTROY:
return DefMDIChildProc(hwnd, message, wParam, lParam);
break;
default:
return DefMDIChildProc(hwnd, message, wParam, lParam);
break;
}
}
/**************************************************
*
* Create a Device Independent Bitmap...
*
*
**************************************************/
void Create_DIB( HWND hWnd )
{
HDC hDC;
unsigned char i;
long k,j, NumBytes;
LPBITMAPINFO info;
unsigned char *dat;
DWORD error;
hDC = GetDC (hWnd) ;
// Intialize BITMAPINFOHEADER data.
//.................................
bi.biSize = sizeof (BITMAPINFOHEADER) ;
bi.biWidth = W;
bi.biHeight = -H; // top-down DIB
bi.biPlanes = 1;
bi.biBitCount = COLORBITS;
bi.biCompression = BI_RGB;
bi.biSizeImage = ( ALIGNLONG( (W * COLORBITS)/8 ) * H);
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 256;
bi.biClrImportant = 256;
// Allocate memory for BITMAPINFO structure.
//..........................................
NumBytes = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD); // +
//( ALIGNLONG( ( W * COLORBITS ) / 8 ) * H );
lpbi = (BITMAPINFOHEADER*)GlobalAlloc( GPTR, NumBytes );
if( lpbi == NULL )
{
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf, 0, NULL );
// Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
exit( EXIT_FAILURE ); // Get out now!
}
// Copy BITMAPINFOHEADER information.
//...................................
*lpbi = bi;
// Create The Palette
info = (LPBITMAPINFO) lpbi;
for ( i=0; i<255; i++ )
{
info->bmiColors[i].rgbRed = i;
info->bmiColors[i].rgbBlue = i;
info->bmiColors[i].rgbGreen = i;
info->bmiColors[i].rgbReserved = 0;
}
// Set pointer to bitmap’s bit data.
//..................................
// lpstBitmap = (LPSTR)lpbi + (WORD)sizeof(BITMAPINFOHEADER) +
// (256 * sizeof(RGBQUAD));
hBitmap = ::CreateDIBSection(hDC,(LPBITMAPINFO)lpbi, DIB_RGB_COLORS,(VOID **)&lpstBitmap, NULL,0);
dat = (unsigned char*)lpstBitmap;
for ( k=0; k< H; k++ )
for ( j = 0; j < W; j++ )
*dat++ = (unsigned char)k;
// Create uninitialized DIB bitmap.
//.................................
/* hBitmap = CreateDIBitmap( hDC,
&bi,
0 ,
0,
(LPBITMAPINFO) lpbi, */
error = GetLastError();
ReleaseDC( hWnd, hDC);
}
void Save(int num)
{
CString prefix = "C:\\Documents and Settings\\Garner Lab\\My Documents\\Hyperspectimages\\image";
char buf[4];
itoa(num, buf, 10);
CString number = buf;
CString suffix = ".bmp";
fullname = prefix + number + suffix;
CImage image;
image.Attach(hBitmap);
image.Save(fullname); // save as BMP
image.Detach();
}
/**************************************************
*
* Force repaint and update the display...
*
*
**************************************************/
void Draw_DIB( HWND hWnd )
{
PAINTSTRUCT ps;
HDC hMemDC;
int scan;
DWORD lasterror;
BeginPaint( hWnd, &ps );
hMemDC = CreateCompatibleDC( ps.hdc );
SelectPalette(hMemDC, palette, TRUE);
RealizePalette(hMemDC);
SelectPalette(ps.hdc, palette, TRUE);
RealizePalette(ps.hdc);
scan = SetDIBits(
hMemDC, // handle of device context
hBitmap, // handle of bitmap
0, // starting scan line
H, // number of scan lines
lpstBitmap, // array of bitmap bits
(LPBITMAPINFO) lpbi, // address of structure with bitmap data
DIB_RGB_COLORS ); // type of color indices to use
if ( !scan )
lasterror = GetLastError();
SelectObject( hMemDC, hBitmap );
BitBlt( ps.hdc, 0, 0, W, H,
hMemDC, 0, 0, SRCCOPY );
DeleteDC( hMemDC );
EndPaint( hWnd, &ps );
}
/**************************************************
*
* Set the bits to the bitmap to be displayed...
*
*
**************************************************/
void Update_Bitmap( HWND hwnd, unsigned short *data, int AutoStop )
{
// Alter The Bits via the pointer
int i,j;
unsigned char *dbits = (unsigned char*)lpstBitmap;
unsigned short *head;
static float mp;
unsigned int max, min;
max = 0;
min = 65535;
head = data;
/* Calculate Scaling Factor */
for (i=0; i for (j=0;j {
if ( min > *head ) min = *head;
if ( max < *head ) max = *head;
head++;
Min = min;
Max = max;
}
mp = (float)256 / ( (float)max-(float)min );
/* Transfer Data to 8 bits */
for (i=0; i for ( j=0;j
*dbits++ = (unsigned char)(((float)*data++ - (float)min)*mp);
// force repaint
InvalidateRect( hwnd, NULL, FALSE );
if( AutoStop ); // Get rid of compiler warning
}
|
|
|
|
|
Firt of all, off topic: read the posting guidelines.
Well, it seems that your image is monochromatic.
Speaking about bitmaps, you cannot transfer 12-bit info into a single channel of RGB, since it (as shown by the code snippet) range 0..255 . You may transfer such a info, for instance, to two (or three) channels, but then you have false colors. I don't know if it is quite acceptable for you (it depends on image usage, for instance diagnostic,...).
You can also use a different scaling algorithm (maybe a scaling more sensitive on differences on low-intensity pixels and less sensitive on high-intensity ones); this choice depends as well on image final usage.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello
I am going to create an IPP Server for Internet Printing .So I need ur help with ur valuable suggestion and any link regarding the IPP...Any suggestion will be appreciated.Please help me... Thanks
Hi
|
|
|
|
|
I recommend you to start with the printing section here in codeproject. There are a lot of articles that will give you info needed to start your programm. Then ask when you get a problem
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
i ve applied accessdeniedace on a process. When i trying to retrieve the Module file name of a window from that process using GetWindowModuleFileName(..), the functiun succeeds and it return the module file name of the calling process. how i can solve this problem ? is there any other way to get the module name of an hWnd ?
Thanks & Regards
|
|
|
|
|
nitin3 wrote: is there any other way to get the module name of an hWnd ?
Yep. the below code will do.
DWORD dwProcessId;<br />
GetWindowThreadProcessId( hWnd, &dwProcessId);<br />
HINSTANCE hModule = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);<br />
if(hModule == NULL)<br />
{<br />
return;<br />
}<br />
HANDLE hProcess = OpenProcess(PROCESS_VM_READ|PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);<br />
if( hProcess == NULL )<br />
{<br />
return;<br />
}<br />
bool bReturn = GetModuleFileNameEx( hProcess, hModule, csLog.GetBuffer( MAX_PATH), MAX_PATH );<br />
csLog.ReleaseBuffer();
Where hWnd is the handle of any window
|
|
|
|
|
Thanks nave..
Thanks & Regards
|
|
|
|
|
Hi,
Iam read and write to external keyboard through serialport RS232.
My coding is
m_hComm = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, 0);
For Reading,
bResult = ReadFile(port->m_hComm,
&RXBuff, // RX Buffer Pointer
1, // Read one byte
&BytesRead,// Stores number of bytes read
&port->m_ov);
For Writing,
bResult = WriteFile(port->m_hComm,// Handle to COMM Port
port->m_szWriteBuffer strlen((char*)port->m_szWriteBuffer),// Length
&BytesSent,// Where to store the number of bytes sent
&port->m_ov);//Overlapped structure
THis is my coding. I can read the dats from serial port.
But while writing,it didnot write.
By having GetLastError(), I got the error as ERROR_IO_PENDING,
Whats the mistake..whats the meaning of this error.
Anu
|
|
|
|
|
Anu_Bala wrote: But while writing,it didnot write.
By having GetLastError(), I got the error as ERROR_IO_PENDING,
Because tou're doing overlapped IO, have a look at documentation http://msdn2.microsoft.com/en-us/library/ms686358.aspx[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
How can I programatically un-select the item in the list (Report view) ?
Thank in advance
Somboon
|
|
|
|
|
xanagan666 wrote: How can I programatically un-select the item in the list (Report view) ?
call SetItemState() function
m_List.SetItemState( nItem, 0, LVIS_SELECTED );
if you know the item index to un-select, you can set that value to the nItem. if you set nItem as -1, all selected items will be unselected.
|
|
|
|
|
I just want to enumerate all the audio video devices installed on the machine.
|
|
|
|
|
Hi Everybody,
I have been trying to save a powerpoint slide from a win32 sdk application.
My Requirment is like this, From my application i need to open a powerpoint application using ole and then save the slides as bitmap .But this is not possible for me to use any mfc based application or active x control.
Can anybody please help me out in this case
Niloy
|
|
|
|
|
I want to do study about Pdf library. Can someone provide me the tutorial on Pdf library. Actually I need to study all the functions, read them what they do because I need to convert the bmp and text to pdf.
|
|
|
|
|
|
Actually I wanted to study Internal working of the CPDFlib. The functions used in that library.
|
|
|
|
|