|
First of all, I'd say your code is clear as water
The docs are rather obscure in this point, but it could be that you have to pass hInstance as the hMod parameter of SetWindowsHookEx --giving it a try is cheap, anyway.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Paying closer attention to the docs, there's a line that says:
All global hook functions must be in libraries
So, you've got to move your code to a DLL. As for why it seemed to work on Debug mode, I guess it is because the executable is run in the context of the debugger process, acting like a sort of DLL on the eye of the system (To check this out, symply execute your debug .EXE by double clicking it outside the IDE. If my theory proves right, you'll get the same behavior as in release mode --no global hooking.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
In my owner draw combobox, MeasureItem doesn't get called (at least when I use AddString ). However DrawItem does get called. But without MeasureItem, the heights are screwed up.
What's wrong?
|
|
|
|
|
Are you using a fixed size combo box?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I'm not.
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~( CBS_OWNERDRAWFIXED | CBS_SORT );
cs.style |= ( CBS_OWNERDRAWVARIABLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS );
Even if I am, MeasureItem should still be able to determine the height of each entry, just not separately.
|
|
|
|
|
How do you make it so any file with a certain extension is opened with your program?
-Raffi
|
|
|
|
|
I answered this question in other thread... here is
THE LINK
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
The alcohol is one of the greatest enemys of man, but a man who flee from his enemys is a coward.
|
|
|
|
|
Does anyone know the maximum value of an unsigned long and a signed long variable in Windows NT ?
Thanks,
Hoang
Hoang Le
|
|
|
|
|
4,294,967,295 (232-1) and 2,147,483,647 (231-1) respectively.
These are declared for your convenience as the macros ULONG_MAX and LONG_MAX in <limits.h> , so you'd better use those rather than the crude numbers.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
And 64-bit versions of NT will of course be 2^64-1 (18,446,744,073,709,551,615). That is why the macros are useful.
// Rock
|
|
|
|
|
The size of types depends on the compiler, not the OS.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Only as a manner of speaking do the size of the types depend on the compiler. It is stated somewhere in the standard that int , for instance, should be the most natural type of the target processor, meaning the size handled naturally by registers and for which the ALU ops are performed in the most efficient way. So, it is nonsense to have non 32-bit int s for 32-bit processors, and the same goes for 64-bit architectures.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
So, it is nonsense to have non 32-bit ints for 32-bit processors, and the same goes for 64-bit architectures.
MS's 64-bit compilers use a 32-bit int to ease Win32-to-Win64 porting.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Oh well, that's a powerful enough reason to retain 32bit int s, I guess.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
MS's 64-bit compilers use a 32-bit int to ease Win32-to-Win64 porting.
Who ever accused MS of following standards?
|
|
|
|
|
What standards are they going against? The C standard says nothing about int having to match the CPU register size.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Right. Now I don't remember the wording, but its meaning is clear: An int shall be the fastest (natural) integral representation for the given target CPU (architecture).
As 64 bits is the natural integer size for a 64-bit CPU, I'd expect that 64-bit integer operations would be the fastest.
|
|
|
|
|
I'm trying to create a bitmap file from a memory device context but the only thing I create is a complete white bitmap.
Here my code:
MyFunction()
{
CClientDC dc(this);
CRect rectBF(0,0,450,450);
CBitmap bmp, *poldbmp;
CDC memdc;
bmp.CreateCompatibleBitmap(&dc, 450, 450);
memdc.CreateCompatibleDC( &dc );
poldbmp = memdc.SelectObject( &bmp );
</A>
m_ctlGraphWnd.DrawGraphToDC(&memdc, rectBF);
memdc.SelectObject(poldbmp);
CPalette palette;
if( dc.GetDeviceCaps(RASTERCAPS) & RC_PALETTE )
{
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 256);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
pLP->palVersion = 0x300;
pLP->palNumEntries =
GetSystemPaletteEntries( dc, 0, 255, pLP->palPalEntry );
palette.CreatePalette( pLP );
delete[] pLP;
}
This code above works correctly. The graph was drawn in memdc.
HANDLE hDIB = DDBToDIB(bmp, BI_RGB, &palette);
if( hDIB == NULL )
return ;
WriteDIB(_T("graph.bmp"), hDIB);
GlobalFree( hDIB );
}
I don't know why but operations done on memdc aren't reflected in CBitmap bmp.
Thanks in advance!
|
|
|
|
|
Hi,
I have a Visual C++ 6.0 that uses a LictControl dialog, it works fine when I edit colums, rows on it! I also can print out its contents ... except:
a) I can not print the column titles
b) Somehow my fonts is very very small
PS: I do have a small zip project file ... I can not attach here. I can send to any one if I have the Email address!
- On the CNewDlg::OnInitDialog() ==> I insert colums titles and row text: OK!
- On the CNewDlg::OnBntPrint() ==> Please help in the // *********> actually do PRINTING here <******** (it locates at the end)
BOOL CNewDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
CString temp, strSQL;
LVCOLUMN column;
LVITEM item;
int i;
char* guestListCol[9] = {"Room#", "Status", "FirstName", "LastName",
"CheckIn", "Until", "ExtraDays", "Adults", "Children"};
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
column.fmt = LVCFMT_LEFT;
temp = "CHECK-IN GUEST LIST REPORT FOR " + COleDateTime::GetCurrentTime().Format("%m/%d/%Y %H:%M:%S");
strSQL.Format ("SELECT * FROM CurrentGuestList WHERE GuestStatus = 'CheckIn'");
UpdateData (false);
for (i=0; i<9; i++)
{
column.cx = 75;
column.iSubItem = i;
column.pszText = guestListCol[i];
m_report.InsertColumn (i, &column);
}
m_report.DeleteAllItems();
item.mask = LVIF_TEXT;
item.iSubItem = 0;
i = 0;
item.iItem = i;
item.pszText = "dummy";
m_report.InsertItem (&item);
m_report.SetItemText (i, 0, "101");
m_report.SetItemText (i, 1, "Check-In");
m_report.SetItemText (i, 2, "John");
m_report.SetItemText (i, 3, "Senior");
m_report.SetItemText (i, 4, "May/20/2002");
m_report.SetItemText (i, 5, "May/22/2002");
m_report.SetItemText (i, 6, "1");
m_report.SetItemText (i, 7, "2");
m_report.SetItemText (i, 8, "4");
return TRUE;
}
void CNewDlg::OnBntPrint()
{
CPrintDialog dlg (FALSE);
if (dlg.DoModal() == IDOK)
{
HDC hdc = dlg.GetPrinterDC();
CDC dc;
DOCINFO docinfo;
memset(&docinfo, 0, sizeof(docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = _T("CDC::StartDoc() Code Fragment");
dc.Attach(hdc);
if (dc.StartDoc(&docinfo) < 0)
MessageBox(_T("Printer wouldn't initalize"));
else
{
if (dc.StartPage() < 0)
{
MessageBox(_T("Could not start page"));
dc.AbortDoc();
}
else
{
m_report.Print(&dc, PRF_NONCLIENT);
m_report.Print(&dc, PRF_CLIENT);
}
dc.EndPage();
dc.EndDoc();
}
}
}
I tried to do a lot of things but failed, can anyone help me?
Thanks
ATC
|
|
|
|
|
i am using this code to put every other letter in a Cstring into a CString variable.
CString mPWD;
CString szTemp;
BOOL bMakePass = TRUE;
CString m_cPwd;
m_cPwd = szPassword;
for (int i = 0; i < m_iPwdLength; i++)
{
if (bMakePass)
{
szTemp = mPWD;
mPWD.Format("%s", m_cPwd.GetAt(i));
szTemp += mPWD;
mPWD = szTemp;
bMakePass = FALSE;
}
else
bMakePass = TRUE;
}
return mPWD;
but it causes the app to crash.
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I'm not any old Eclypse, i'm TheEclypse..get it, got it, good!"
|
|
|
|
|
CString s = "Hello World from Nish";
CString t="";
for(int i=0;i<s.GetLength();i+=2)
t+=s[i];
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
While Nish gave you a solution that works more efficiently than the code you posted here, the reason you code gives you an error is because your
mPWD.Format("%s", ... statement is wrong. You are passing in a single character, not a string, so you should have used
mPWD.Format("%c", ... instead.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
I need to convert a CString to a char.
Unless anyone know how to pick the 3rd character in on a CString.
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I'm not any old Eclypse, i'm TheEclypse..get it, got it, good!"
|
|
|
|
|
use GetAt()
for example if CString temp="test"
out=temp.GetAt(3);
!! Put it in a if statement to prevent a asertation error:
if temp.GetLength()>2{ // e.g. 3
out=temp.GetAt(3);
}
Hope that helped.
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
|
|
|
|
|
You can do it just like it was a char string.
CString m_sTest;
char c;
c = m_sTest[2];
You could also use the Mid function on the CString.
Ed
|
|
|
|
|