|
johanlich wrote: CmyDialog dlg; dlg.DoModal();
If you copy the above code and paste it in the InitInstance of the app, does it shows the dialog correctly?
|
|
|
|
|
Did you use ClassWizard, or equivalent, to create CmyDialog ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I used the ClassWizard to create CmyDialog, and the “Add Resource” tool to create the dialog-window (using MS Visual Studio 2005).
When I copy “CmyDialog dlg; dlg.DoModal()” to InitInstance the main window locks up as if there were a modal window, but the window does not show up on the screen (had to add some #includes into my main apps cpp-file since the CmyButton class is in another catalogue).
Thanks for the quick replies.
// Johan
|
|
|
|
|
In that case the button-thing is irrelevant. It's a problem with your dialog box.
Is the visible style set?
Can you put a breakpoint in the OnInitDialog and see it fire?
You can also set a no-fail-create flag, which is very useful. If there is a problem with a control on the dialog, the whole dialog creation would fail. (Mind you, DoModal should just return almost immediately...)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi all,
I have a strange issue where an app which I'm getting events from is sometimes producing right click events when a left mouse click is actually what happened. Is there a windows buffer I can read which will allow me to validate the event without having to record all the mouse events myself.
Thanks
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
I'm now using the lines:
SHORT rbstate = GetAsyncKeyState(VK_RBUTTON);
if (!rbstate) {
return;
}
It just makes sure the right mouse button was the one used.
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
Just want to add a little note. GetAsyncKeyState will return the state at the moment you're calling it, which will always be slightly later than the moment the message was generated.
That shouldn't be a problem normally, but you might want to keep that in mind.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
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
|
|
|
|