|
Thanks, but I get it same result if I do this:
::MessageBox( m_hWnd, "Bla bla bla", NULL, MB_OK);
I have checked with Spy++ and the handles are set up correctly.
However, I have found a workaround. I handle the WM_SETFOCUS message in the dialog. If the dialog gets focus and the window isn't enabled, it tries to change the focus to the popup window:
LRESULT CDialog2::OnSetfocus(WPARAM wParam, LPARAM lParam)
{
if(!IsWindowEnabled())
{
HWND child = ::GetWindow(m_hWnd, GW_HWNDPREV);
if(child != NULL)
{
TRACE(_T("Has child!\n"));
::SetFocus(child);
}
}
return 0;
}
I don't like this solution sense I doesn't understand what's going on, but I guess I could live with that.
|
|
|
|
|
Hi,
i'm developing an MDI-application with mfc .net . Now i have the question how to change the Background-Color, so that Menu, Toolbar and Statusbar - even everything - has the same style.
I first thought that updating the Function AfxRegisterWndClass(...) with my own background-brush will help. But it doesn't work. Than I tried CWinApp::SetDialogBkColor() but its not available in Visual C++ 7.
Handling the WM_CTLCOLOR or WM_ERASEBKGND messages also did no effect.
Is there any way or am i hit with blindness?
Thanx
Jo
|
|
|
|
|
Hi all, to get the real printable area of a page (on a printer of course)
is it correct to do it like this?
assuming that i want to use HIMETRIC, mydc is a device context (CDC class), and it has allready been "opened" to my printer...
dc.SetMapMode(MM_HIMETRIC);
CSize pagesize;
// get the "physical" size of the page...
pagesize.cx=dc.GetDeviceCaps(PHYSICALWIDTH);
pagesize.cy=dc.GetDeviceCaps(PHYSICALHEIGHT);
// now take off the non printable area
pagesize.cx-=dc.GetDeviceCaps(PHYSICALOFFSETX);
pagesize.cy-=dc.GetDeviceCaps(PHYSICALOFFSETY);
// returned values were in device units, we need himetric
dc.DPtoHIMETRIC(&pagesize);
// pagesize now has the real printable area of the page
is this correct? is there a better way?
thanks!
|
|
|
|
|
In some, if not most cases, I have found that the PHYSICALOFFSETX and PHYSICALOFFSETY would apply to BOTH edges of the page, so you might want to do your math like this:
// now take off the non printable area
pagesize.cx-= (2 * dc.GetDeviceCaps(PHYSICALOFFSETX));
pagesize.cy-= (2 * dc.GetDeviceCaps(PHYSICALOFFSETY));
I also don't think this accounts for any of the margins the user might have set for the printing area.
You might want to also obtain the printer device context (CreateDC) and examine the DEVMODE fields:
dmYResolution - Specifies the y-resolution, in dots per inch, of the printer. If the printer initializes this member, the dmPrintQuality member specifies the x-resolution, in dots per inch, of the printer.
Or you can get the from associated with a print job and check these fields:
Size - Specifies the width and height, in thousandths of millimeters, of the form. ImageableArea - Specifies the width and height, in thousandths of millimeters, of the form.
|
|
|
|
|
hai,
I need to find the port which is precently active and set the port settings and send date to that particular port and to receive data from that port,how am i to do it?
mithila
|
|
|
|
|
What kind of ports you meen : COM, LPT, USB ?
|
|
|
|
|
Can enyone tell me where I can find C or C++ code for Nicholl-Lee- Nicholl, line clipping, alghoritm. If you know where i can find it or you have it please send it to my e-mail: taj_sam@yahoo.com.
Thanks in advance....
|
|
|
|
|
Dunno about code, but the algorithm can be found here[^].
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
does anyone know how to deselect a list ctrl item ive tried
list.SetItemState(i, 0, 0);
but this doesnt work
anyone have any idea
thanks
|
|
|
|
|
You'll need to handle LVN_ITEMCHANGING and return FALSE to allow the item to be (un)checked or (de)selected and return TRUE to disallow a change.
Here's some code that might help.
Add this to your CMyListCtrl class definition as a protected function:
// Returns TRUE if the item is checked, false if it is not or uState == 0
inline BOOL IsChecked(UINT uState) {return
(uState ? ((uState & LVIS_STATEIMAGEMASK) >> 12) - 1 : FALSE);}
Here's a sample function for handling LVN_ITEMCHANGING:
void CTestListView::OnItemchanging(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// If old state is unchecked and new state is checked
// then item is being checked.
if ((! IsChecked(pNMListView->uOldState)) &&
(IsChecked(pNMListView->uNewState)))
MessageBox("Item is being checked");
// If old state is checked and new state is unchecked,
// item is being unchecked
else if ((IsChecked(pNMListView->uOldState)) &&
(! IsChecked(pNMListView->uNewState)))
MessageBox("Item is being unchecked");
// return FALSE (or 0) to allow change, TRUE to prevent
*pResult = 0;
}//OnItemchanging
Select: m_ListCtrl.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
Deselect: m_ListCtrl.SetItemState(iItem, 0, LVIS_SELECTED);
Focused: m_ListCtrl.SetItemState(iItem, LVIS_FOCUSED, LVIS_FOCUSED);
Unfocused: m_ListCtrl.SetItemState(iItem, 0, LVIS_FOCUSED);
|
|
|
|
|
Look at your call, the 3rd param is which state bits you want to change. Since you pass 0, no bits are changed. Pass LVIS_SELECTED in that parameter to turn off that state bit.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
#include "witty-quote.h"
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
Has anyone created an SWF file from code?
I have heard this can be done.
Carl
|
|
|
|
|
Hello,
I have an app installing a mouse hook:
The hook setup function...
BOOL CXCapture::Setup()
{
DFUNC_DEF(CXCapture::Setup);
BOOL bRetVal;
m_hMouse = ::SetWindowsHookEx(WH_MOUSE, &MouseProc, ::AfxGetInstanceHandle(), NULL);
bRetVal = m_hMouse != NULL;
DFUNC_RET(bRetVal != FALSE, DSTR("Could not initialise mouse_hook (Err#%d)", GetLastError()));
return bRetVal;
}
The callback function...
LRESULT CALLBACK CXCapture::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
DFUNC_DEF(CXCapture::MouseProc);
DTRACE(DSTR("Hook: %d::%d, %d", nCode, wParam, lParam));
return ::CallNextHookEx(m_hMouse, nCode, wParam, lParam);
}
It happens that while the mouse is inside my application's (only) dialog box, the callback function (MouseProc ) is called flawlessly, but when the mouse focus is out of the window, the OS simply unhooks it.
Therefore, whenever the mouse leaves the app's window focus, I am left out with no mouse hook whatsoever!!
My question is why this is happening and what should (or can) I do in order to solve this.
All feedback is greatly appreciated.
David Nimrod
|
|
|
|
|
The Callback function needs to reside in a DLL. the each process can load the dll into it's own address space.
Carl
|
|
|
|
|
Yeah, I've read about that just an hour ago or so and am modifying the code.
Thanks for the reply.
David
|
|
|
|
|
Hello everyone, i have question that has been a problem to me for couple of days. I am new to db programming so bare with me.
I have a login dialog where the user enters a password, and i am trying to search my employee db to find out of that person is in the db..I simply do not know how to search my db and see if the person is an employee.
here is my code...if anyone could help out, it would be great.
//getting password from and edit box
CEdit *ebptr = (CEdit *) GetDlgItem(IDC_TEXTBOX);
int i;
char str[80];
i = ebptr->GetWindowText(str, sizeof str-1);
//set my password
box_password = str;
///THIS IS WHERE I DONT HAVE ANY CLUE, HOW TO SEARCH MY DB //FOR THE PASSWORD, PLUS HOW DO I KNOW IF THE PASSWORD EXITS IN THE DATABASE?????
rsEmployeeSet.m_strFilter = "password = box_password";
rsEmployeeSet.Open();
|
|
|
|
|
CString strValue = _T("4");
int nValue = 0;
int nMatches = _tscanf (strValue.GetBuffer(0), _T("%d"), &nValue);
strValue.ReleaseBuffer(); nMatches is zero. Why?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi Ravi,
I think you've got the wrong function here:
"The scanf function reads data from the standard input stream stdin and writes the data into the location given by argument."
It should be: _stscanf()
Maybe the ham sandwich's are running low.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Neville Franks wrote:
Maybe the ham sandwich's are running low.
In fact, they are!
Many thanks for the _stscanf() correction - I really must sleep more than 5 hours each night.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Also, you don't need to call GetBuffer on CString as you are not writing to it's data. So somthing like this will be more efficiant:
CString strValue = _T("4");
int nValue = 0;
int nMatches = _stscanf (strValue, _T("%d"), &nValue); It saves you a whole function call... WAHOO!
Joel Holdsworth
|
|
|
|
|
Actually, two: both the GetBuffer() and the ReleaseBuffer() calls.
Oh, wait. You've added a call (the implicit cast to LPCTSTR ).
Never mind .
Software Zen: delete this;
|
|
|
|
|
Exactly... they don't come free you know
Joel Holdsworth
|
|
|
|
|
Hi,
I'm having problems painting with alpha in GDI. If I go:
backdc.FillSolidRect(&clientrect, 0xFF012345); What I end up with on the final bitmap surface is:
00 01 23 45 Does anyone know a way to overcome this?
Joel Holdsworth
|
|
|
|
|
The nearest function I can see to what you want would be the function AlphaBlend, though it looks
pretty fiddly to use.
Iain.
|
|
|
|
|
Yeah I've ended up using GDI+ now. It seems to the job nicly! I initially just wanted to avoid too many dependancies.
Joel Holdsworth
|
|
|
|
|