|
Thanks for the response.
GetAsyncKeyState also returns a value > 0 if the key was pressed since the last call to it as well as if the event is currently active. If I'm checking for the right mouse key and someomeone enters the sequence: right key, left key, right key and I make a call each time, I should at least get 0,0 1.
To counteract the first false negative I ignore the first call's result assuming that the first right click event is always correct as in this case the first event is what sets off the problem.
I'm assuming this is what is going on as it now works.
It's not the way I would have chosen. I'll have to keep an eye on it.
Again, thanks for the comment,
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
I got the below given fatal error while converting a 32 bit application to 64 bit.Any one plz give a solution for this.
Error: mfcs42u.lib(nolib.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
It appears to me quite informative...
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
thanks for the reply
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
Hi Friends,
I am facing a problem with print preview, actually in the print preview window when we click the print button the preview button closes and print dialog comes up. I want the preview window should not close. Can any one help me how to do that.
thanks,
pradeep
|
|
|
|
|
You may need to create custom preview class.
Have a look at [TN030: Customizing Printing and Print Preview^]
I tried some thing now, sorry i don't have easy solution,
create a new class CMyPreviewView derived from CPreviewView use #include <afxpriv.h> in stdafx.h
overide the Print command handler in the preview view,
BEGIN_MESSAGE_MAP(CMyPreviewView, CPreviewView)
ON_COMMAND(AFX_ID_PREVIEW_PRINT, &CMyPreviewView::OnPreviewPrint)
END_MESSAGE_MAP()
so that you have the control of print button in CMyPreviewView::OnPreviewPrint and here you won't close the preview window
<small>void CMyPreviewView::OnPreviewPrint()
{
m_pOrigView->SendMessage(WM_COMMAND, ID_FILE_PRINT);
}</small>
make your custom preview class as Document preview class by calling DoPrintPreview,
<small>void CMyViewToBePrinted::OnFilePrintPreview()
{
CPrintPreviewState* pState = new CPrintPreviewState;
TRY
{
if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CMyPreviewView), pState))
{
TRACE(traceAppMsg, 0, "Error: DoPrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState;
}
}
CATCH_ALL(e)
{
delete pState;
THROW_LAST();
}
END_CATCH_ALL
}</small>
modify the View message maps as,
<small>BEGIN_MESSAGE_MAP(CMyViewToBePrinted, CView)
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMyViewToBePrinted::OnFilePrintPreview)
END_MESSAGE_MAP()</small>
|
|
|
|
|
Hi Rajkumar,
Sorry for late reply.
In our application the CPreviewView class was already customized but not the OnPreviewPrint function. so i derived that and added the code. Now when i click the print button in the print preview window the preview window remains and print dialog comes up, but whenever i give OK or CANCEL on the print dialog automatically both the print dialog & preview window closes. I am not understanding why it is happening like that. Did you tried the above in your application, how was the behaviour??
|
|
|
|
|
Not Sure, I don't have time to debug. BTW, in my application, the preview window is not closing when the print dialog cancel button is pressed. You have the complete MFC source code in Visual Studio SDK folder, you can find the reason by debugging them.
|
|
|
|
|
I am using ChooseFont function for selecting font .I want to persist the font data . i.e. when I select the font then they should be reflect in font dailog box when again I call ChooseFont function.How can I achive this.
Trioum
|
|
|
|
|
What about documentation [^]?
lpLogFont
Pointer to a structure. If you set the CF_INITTOLOGFONTSTRUCT flag in the Flags member and initialize the LOGFONT members, the ChooseFont function initializes the dialog box with a font that is the closest possible match. If the user clicks the OK button, ChooseFont sets the members of the LOGFONT structure based on the user's selections.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi all,
i am using a function to retrieve the drive letter of a USB drive from WMI with the deviceID i have with me, as it is with the specific deviceID and the corresponding drive letter, i create a file to monitor activities on the USB.
the deviceID which i have with me is in the format "USB\\VID_0980&PID_762A\\..." which i retrieve at the moment a USB drive is inserted. in my function i take this deviceID as input and map the drive letter corresponding to it.
as i have looked upon and subsequently found out that the mapping of drive letter in WMI has been done by taking the deviceID in the format "USBSTOR\\DISK&Ven_TOSHIBA&PROD_TRA........".
the DeviceID "USBSTOR\\DISK&Ven_TOSHIBA&PROD_TRA......." can be achieved from WIN32_PnpEntity.DeviceID and also from WIN32_USBControllerDevice.Dependent
the DeviceID "USB\\VID_0980&PID_762A\\..." can be retrieved from WIN32_PnpEntity.DeviceID and also from WIN32_USBControllerDevice.Dependent.
although both these deviceID are from the same USB device the mapping for drive letter is done thorugh the previous one i.e "USBSTOR\\DISK&Ven_TOSHIBA&PROD_TRA......."
and i am not getting a link between these two DeviceIDs.
so please can i get some help on how to retrieve the drive letter of USB device using the device ID "USB\\VID_0980&PID_762A\\..."
Thank You.
|
|
|
|
|
Hi,
i´ve the same problem at the moment. Did you find a solution yet?
|
|
|
|
|
Hello everyone
Happy new year!
Here is my problem:
I have 2D images where each pixel data is stored in an unsigned short (16bits) but the information in the image never exceed 12 bits. For compression purpose, I would like to save in file only 12bits for each pixel of my images.
Have you experience the same problem? any idea on how to do so?
Thanks
Alf
----------------------
|
|
|
|
|
alfalf3 wrote: Have you experience the same problem?
No.
alfalf3 wrote: any idea on how to do so?
Yes: write a couple of functions, for instance:
BOOL SaveBmpTo12BitsFile(HBITMAP hBmp, HANDLE hFile);
HBITMAP LoadBmpFrom12BitsFile(HANDLE hFile);
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You can use the below code to convert 2 unsigned shorts (4 bytes) into 3 bytes.
unsigned short s1 = 10;
unsigned short s2 = 20;
BYTE b1 = (s1 & 0x0FF0) >> 4;
BYTE b2 = (s1 & 0x000F) << 4;
b2 |= (s2 & 0x0F00) >> 8;
BYTE b3 = s2 & 0x00FF;
s1 = b1 << 4;
s1 |= (b2 & 0xF0) >> 4;
s2 = (b2 & 0x0F) << 8;
s2 |= b3;
«_Superman_»
|
|
|
|
|
Thank you _Superman_ (sounds weird )
I found a way (not the smartest I think) without bit shift:
typedef struct _PackedUShort
{
unsigned char b0 : 4;
unsigned char b1 : 4;
unsigned char b2 : 4;
unsigned char b3 : 4;
} PackedUShort;
typedef union
{
unsigned short us;
PackedUShort pack;
} PackedData;
packBuf = (PackedData*) myImageBuffer;
resultBuf = (PackedData*) malloc(sizeof(PackedData) * newSize);
for(i=0; i<imagesize;>{
int position = j % 4;
switch(position)
{
case 0:
(*resultBuf).pack.b0 = (*packBuf).pack.b0;
(*resultBuf).pack.b1 = (*packBuf).pack.b1;
(*resultBuf).pack.b2 = (*packBuf).pack.b2;
break;
case 1:
(*resultBuf).pack.b1 = (*packBuf).pack.b0;
(*resultBuf).pack.b2 = (*packBuf).pack.b1;
(*resultBuf).pack.b3 = (*packBuf).pack.b2;
resultBuf++;
break;
case 2:
(*resultBuf).pack.b2 = (*packBuf).pack.b0;
(*resultBuf).pack.b3 = (*packBuf).pack.b1;
resultBuf++;
(*resultBuf).pack.b0 = (*packBuf).pack.b2;
break;
case 3:
(*resultBuf).pack.b3 = (*packBuf).pack.b0;
resultBuf++;
(*resultBuf).pack.b0 = (*packBuf).pack.b1;
(*resultBuf).pack.b1 = (*packBuf).pack.b2;
break;
}
j+=3;
packBuf++;
}
}
----------------------
|
|
|
|
|
Hi Friends,
I have a dialog based MBCS application which creates the EDIT control over the dialog using CreateWindowExW API to support languages like Chinese, Japanese etc.
When I paste the Chinese characters into the EDIT control, it displays it correctly.
I call the GetWindowTextW to extract the content from the control into a wchar_t buffer.
But the debugger is not showing the value unless I call CharToOemW. What CharToOem does on that buffer? I would like to know more details with a functional comparison of APIs, WideCharToMultiByte and CharToOem.
Thank you
cheers
Varghese Paul
|
|
|
|
|
Please check whether you have enabled - "Display Unicode strings" option under Tools > Options > Debug tab.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
All multi-byte functions work on char buffers and not on wchar_t buffers.
«_Superman_»
|
|
|
|
|
Varghese Paul M wrote: But the debugger is not showing the value unless I call CharToOemW. What CharToOem does on that buffer?
I think that the CharToOEM function is converting the string buffer from UTF-8 into the default codepage on your operating system.
Code Page Identifiers[^]
Code Pages[^]
Code page[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi, I'm able to set the text and the background color of the text for Status bar, but I'm not able to set the color for the 'seperator' of the status bar.
I have 3 column on the status bar, each of the text and background I'm able to set it but have no luck on the 'seperator'
I've done it by creating a custom status bar inherited from CStatusBar
By drawing it on DrawItem
CODE:
CDC oDC;
CDC* pdc = CDC::FromHandle(pDIS->hDC);
pdc->FillSolidRect(&pDIS->rcItem, RGB(255,255,255));
oDC.Attach(pDIS->hDC);
oDC.SetTextColor(RGB(255,0,0));
oDC.SetBkColor(pDIS->itemData);
pDIS->rcItem.left += 2;
oDC.DrawText(_T("Test"),&pDIS->rcItem,DT_LEFT);
oDC.Detach();
Any ways to do this?
I wanted to change the whole status bar into white color RGB(255,255,255)
Any help would be appreciated.
KH
good
|
|
|
|
|
Is there any ways for me to set the seperator on the status bar become smaller?? by default, the width of it is 0.1cm
Or can I disable/remove the seperator between the item in the status bar ??
good
modified on Tuesday, January 13, 2009 3:03 AM
|
|
|
|
|
Did you try to handle the WM_CTLCOLOR to change the status bar color?
«_Superman_»
|
|
|
|
|
Do i Change the WM_CTLCOLOR on my CCustomStatusBar or on the MainFrm ?
KH
good
|
|
|
|