|
Hi all,
I am looking for an example demonstrating how to build a sliding window, like the one that slides up above the system tray when a new message comes. If you can provide a link or brief example, you'd really help me out. Thanks in advance.
|
|
|
|
|
Hi folks. I decided to start collecting FAQs from this forum, and below is a list of the questions I could remember, along with a really brief answer. I'll expand on the answers in the final FAQ, naturally.
If you can think of any additional ones, please mail them to me at mike@codeproject.com.- Why don't my #include lines show up right in the forum? [Use < and > instead of < >]
- I'm trying to call a Windows API, but the compiler gives an undeclared identifier error. What's up? [#define the right values for WINVER, _WIN32_WINNT, _WIN32_IE]
- Why do I get an unresolved external on main() in ATL project release builds? [#undef _ATL_MIN_CRT]
- I added some source files I got from someone else and the compiler says "couldn't find precompiled header." What's up? [#include "stdafx.h" or disable use of PCHs as appropriate]
- Thanks. Now, what's a PCH?
- What does a debug assert failed mean? [you have a bug]
- How do I change the background color of a dialog, or draw a picture as the background? [WM_ERASEBKGND]
- How do I change the cursor when it's in my window? [WM_SETCURSOR]
- How do I show/hide a window? [ShowWindow()]
- How do I enable/disable a dialog control (button, etc)? [EnableWindow()]
- In my MFC app, why doesn't EnableMenuItem() have any effect? [Use ON_UPDATE_COMMAND_UI instead]
- Why can't I use a member function as a callback? [Make it static, or use a global function and pass it this, then call pThis->MemberFunc()]
- I'm trying to use cout and cin, but the compiler gives an undeclared identifier error. What's up? [std::cout or using namespace std]
--Mike--
http://home.inreach.com/mdunn/
"Holding the away team at bay with a non-functioning phaser was an act of unmitigated gall. I admire gall."
-- Lt. Cmdr. Worf
|
|
|
|
|
Hi All!
If I have, for example, the bits of a DIBSection and I want to set it to a given (32 bit) color, I could say:
(1)
for (int i=0; i<nPixels; i++) pbits[i] = mycolor;
or:
(2)
__int32 *p=pbits;
while (p<pbits+nPixels) *p++ = mycolor;
but if I wanted to set it to black (or a similar color where the components are all the same) then I could just say:
(3)
memset(pbits, 0, nPixels*4);
So I guess I'm wondering if there's a way to replace (1) and (2) by a built-in function that I don't know about but which looks something like:
memset_32_at_a_time(pbits, mycolor, nPixels);
(and which would presumably be faster than either of the first two methods)
Thanks for any help with this!
|
|
|
|
|
You might use std::fill or std::fill_n. There are no C runtime library functions for this.
|
|
|
|
|
Alex,
memset does almost exactly what you do in your second function (unless you using an Alpha or PowerPC chip set, which calls RtlFillMemory). You could use memcpy in a loop, but I doubt it would give you any enhancements in speed.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Thanks for the responses!
Continuing on Ben's idea, I could manually set the values of the first scanline and then memcpy it to the other scanlines. However my original goal wasn't mainly speed gain but rather to make the code nicer, so I guess I'll give it a miss and just set the values manually
|
|
|
|
|
Hi all,
How can i set bitmap for background in SDI ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi,
I found my answer ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I am building a library that will be linked to dynamically by other applications. In the library I load strings from the resource string table for the DLL using CString::LoadString(nID). The problem is that once the DLL is loaded, CString::LoadString(nID) tries to load the string resource from the applications resource table, rather than the DLLs.
I have tried setting the resource handle (using AfxSetResourceHandle(…)) both sides of the call, but it still looks for the string in the applications resource.
How can I get it so an calls in the DLL’s code to CString::LoadString(nID) load the string from the DLL’s resource table, and any calls in the application’s code load the string from the app’s resource table. Get it?
Any help would be appreciated. I have tried searching my installed MSDN, but nothing came up that I could see to be useful.
Cheers,
James Millson
|
|
|
|
|
try the ::LoadString API function (instead of CString::LoadString).
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Thanks, that worked perfectly.
|
|
|
|
|
Hi there.
I want to write ActiveX, my base ActiveX is a EditBox ...
So i add EditBox in my dialog, but when i compile my ActiveX, i see only a ellipse in form !!!
Why ??? How can i solve it ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I still haven't been able to solve my problem with the ::IsWindow asserting in the dll when call SetWindowText() in the dll for the main application dialog.
To make this more understandable I have upload a test application that shows the problem. full source code is attached with it and you must rebuild it, I delete all object and exe files so the download will not take to long. The file is under 500k byte and includeds both the App and DLL.
-load the workspace for the app,.. this work spaces is setup so if you just rebuild all it should compile and run. When runnning you will notice that the DLL IsWindow fails?! why?! I need help here.
here is the link to download the test program:
www.marino.dk/misc/dlltest01.zip
plz note, always run the debug version!!
Peter Marino ( www.marino.dk )
Programmer for IO Interactive ( Hitman Codename 47 )
|
|
|
|
|
Try setting both the DLL and the exe to use either static or DLL MFC library.
Before fixing that, I couldn't link, after fixing that I couldn't crash.
|
|
|
|
|
ok, now I'm completly confused, but your solution seems to work?!
another strange thing is that the compiler can't find the AfxLoadLibrary when using static, which I also find very confusing.... I'm now trying to use your fix in my main project,.. hope it works,...
thx a lot
Peter Marino ( www.marino.dk )
ps: finished testing in my main application,.. it works jubii!!! If you ever come to Denmark then I'm buying you dinner
|
|
|
|
|
Hi all. I am very new to Visual C++ and would be grateful for some pointers for the following. I am attempting to embed a scrollable view into a form view. It would like a CScrollView, but obviously non-resizable. I have got as far as creating an object based on CWnd, embedded it into a form view and drawn into it, but I have no idea how to create a "canvas" larger than the size of the object and handle the mechanics of scrolling. Can anyone point me in the direction of some scrolling code, or tell me a way of doing it? Thanks
|
|
|
|
|
If you create a new dialog (ie: wizard), delete all the gadgets from it then go it its properties and turn on vertical scrolling. You will need to play with the SCROLLINFO structure (add a member of new dialog class).
eg:
CDialogContainer::OnInitDialog()
{
CDialog::OnInitDialog();
m_pScrollInfo = new SCROLLINFO;
m_pScrollInfo->cbSize = sizeof(SCROLLINFO);
m_pScrollInfo->fMask = SIF_ALL;
m_pScrollInfo->nMin = 0;
m_pScrollInfo->nMax = 100;
m_pScrollInfo->nPage = 10;
m_pScrollInfo->nPos = 0;
m_pScrollInfo->nTrackPos= 0;
this->SetScrollWindow();
...
}
You will also need :
// ----------------------------------------------------------------------------
// Method: OnVScroll
//
// Abstract: Maintains the scroll bar.
// Called automatically from the scrollbar events
// Also called manually to update the scrollbar after changes.
//
// Arguments:
//
// UINT nSBCode : The Scroll type
// UINT nPos : For ScrollType SB_THUMBPOSITION nPos is the new position
// CScrollBar* pScrollBar : Ignored (usually NULL anyway)
//
// ----------------------------------------------------------------------------
void CDialogContainer::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
RECT rectClient;
int iButtonIncrement;
int iPageIncrement;
int iScrollAmount = 0;
//////////////////////////////////////////////////////////////
// Not interested in ENDSCROLL events.
//////////////////////////////////////////////////////////////
if (SB_ENDSCROLL == nSBCode)
return;
//////////////////////////////////////////////////////////////
// If we get events which would cause the scrolling to leave
// the range then just return.
// ie: Pressing the scrollup when its already up.
//////////////////////////////////////////////////////////////
if ( (m_pScrollInfo->nPos <= m_pScrollInfo->nMin) && (nSBCode == SB_LINEUP) )
return;
if ( (m_pScrollInfo->nPos <= m_pScrollInfo->nMin) && (nSBCode == SB_PAGEUP) )
return;
if ( (m_pScrollInfo->nPos >= m_pScrollInfo->nMax) && (nSBCode == SB_LINEDOWN) )
return;
if ( (m_pScrollInfo->nPos >= m_pScrollInfo->nMax) && (nSBCode == SB_PAGEDOWN) )
return;
this->m_vectorCDialogAddress[0]->GetClientRect(&rectClient);
iButtonIncrement = (rectClient.bottom - rectClient.top)/4;
iPageIncrement = (rectClient.bottom - rectClient.top);
switch (nSBCode)
{
case SB_LINEUP:
iScrollAmount = -iButtonIncrement;
break ;
case SB_LINEDOWN:
iScrollAmount = iButtonIncrement;
break ;
case SB_PAGEUP:
iScrollAmount = -iPageIncrement;
break ;
case SB_PAGEDOWN:
iScrollAmount = iPageIncrement;
break ;
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
{
if (nPos > m_pScrollInfo->nMax)
nPos = m_pScrollInfo->nMax;
if (nPos < m_pScrollInfo->nMin)
nPos = m_pScrollInfo->nMin;
iScrollAmount = nPos-m_pScrollInfo->nPos;
}
break;
}
if ( (SB_LINEDOWN == nSBCode || nSBCode == SB_PAGEDOWN) &&
(m_pScrollInfo->nPos + iScrollAmount > (m_pScrollInfo->nMax - m_pScrollInfo->nPage)) )
{
//////////////////////////////////////////////////////////////
// Round off the last piece to the leftover amount
//////////////////////////////////////////////////////////////
iScrollAmount = (m_pScrollInfo->nMax - m_pScrollInfo->nPage - m_pScrollInfo->nPos);
}
if ( (SB_LINEUP == nSBCode || nSBCode == SB_PAGEUP) &&
(m_pScrollInfo->nPos + iScrollAmount < m_pScrollInfo->nMin) )
{
//////////////////////////////////////////////////////////////
// Round off the last piece to the leftover amount
//////////////////////////////////////////////////////////////
iScrollAmount = (m_pScrollInfo->nMin - m_pScrollInfo->nPos);
}
m_pScrollInfo->nPos += iScrollAmount;
this->ScrollWindow(0,-iScrollAmount); // opposite direction on scroll bar!
this->SetScrollInfo(SB_VERT,m_pScrollInfo,TRUE);
}
BOOL CDialogContainer::OnCommand(WPARAM wParam, LPARAM lParam)
{
//////////////////////////////////////////////////////////////
// Prevent Enter and ESC from closing the control.
//////////////////////////////////////////////////////////////
if (wParam == IDOK)
return FALSE;
if (wParam == IDCANCEL)
return FALSE;
return CDialog::OnCommand(wParam, lParam);
}
//////////////////////////////////////////////////////////////
// iIndex of -1 means preserve the position.
//////////////////////////////////////////////////////////////
void CDialogContainer::SetScrollWindow(int iIndex)
{
RECT rectClient ;
RECT rectDialogRect;
int iHeight;
int iScrollPos;
iScrollPos = m_pScrollInfo->nPos;
m_pScrollInfo->nPos = 0;
this->SetScrollInfo(SB_VERT,m_pScrollInfo,FALSE);
this->GetClientRect(&rectClient);
for (int i=0;i<m_vectorcdialogaddress.size();++i)
{
="" m_vectorcdialogaddress[i]-="">GetClientRect(&rectDialogRect);
iHeight = rectDialogRect.bottom - rectDialogRect.top;
rectDialogRect.top = (iHeight * i);
rectDialogRect.bottom = rectDialogRect.top + iHeight;
m_vectorCDialogAddress[i]->MoveWindow(&rectDialogRect);
m_vectorCDialogAddress[i]->ShowWindow(SW_SHOW);
}
int iRangeMax = (iHeight*m_vectorCDialogAddress.size());
if (iRangeMax <= (rectClient.bottom - rectClient.top))
{
this->EnableScrollBar(SB_VERT,ESB_DISABLE_BOTH);
iRangeMax = 0;
}
else
{
this->EnableScrollBar(SB_VERT,ESB_ENABLE_BOTH);
}
m_pScrollInfo->nPos = 0; // As we are going to SCROLL to where we want.
m_pScrollInfo->nMax = iRangeMax; // Total Height
m_pScrollInfo->nPage = (rectClient.bottom - rectClient.top); // Visable Height
this->SetScrollInfo(SB_VERT,m_pScrollInfo,FALSE);
//////////////////////////////////////////////////////////////
// Explicit scroll to the supplied entry.
//////////////////////////////////////////////////////////////
if (iIndex != -1)
this->OnVScroll(SB_THUMBPOSITION,iIndex*iHeight,NULL);
this->ShowScrollBar(SB_VERT,TRUE);
}
Julien.
|
|
|
|
|
|
I tried several things now but my CBitmap still appear under Cstatic bmp and Cstatic control
when using Onpaint. (CpaintDc)
How is drawed the screen ? is there priority that we can set ?
a kind of Z buffer ? anythings ?
|
|
|
|
|
Hi All,
I am using VC++6.0 to do the C++ Program. I want to draw a Graph in Console window. Is it possible to do ?Then which is the header file to be included??
Thanks in Advance
Rgds
Sangeetha
|
|
|
|
|
No, you can't ...
I'm sure, i think my answer is clear, so i don't explain.
Cheers ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
yes. you can, or at least you could. i wrote many programs using Microsoft's older C compilers using the DOS VESA drivers. i even wrote my own windowing system before Windows 3.0 came out. and, all my old programs still run in the current DOS windows.
i honestly have no idea if the current batch of Visual C++ compilers let you do this or not (i suspect not). but, if you can find an old MS C compiler (pre v7 i think) you're all set.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Hello,
I am trying to write an application in WTL with Horizontal Splitters. Could some one send me a link or code to create splitter in WTL.
Thanks in Advance
Regards
Alpesh Makwana
|
|
|
|
|
Can anybody tell me how can i programmatically send and receive mails from any mail account for ex hotmail.com like outlook express does.
|
|
|
|
|
Sending and receiveing mail progrmatically like hotmail is possible by using the SMTP and POP3 Protocol wrappers that are available on CodeProject Site.
http://codeproject.com/internet/csmtpconn.asp by PJ Naughter could help in this.
Thanks in Advance
Regards
Alpesh Makwana
|
|
|
|