|
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
|
|
|
|
|
That's a really complex question though like most complex questions it is much easier to state.
Here are a few hints for direction:
1. Learn WinSock or BSD sockets (you'll need them).
2. Read through RFC 821 (SMTP) most of it might be confusing if your not used to "grammars" but you can get the protocol quite easily. This is how internet mail is propogated (aka sent and passed on).
3. Read through RFC 1939 (POP-3) the same goes as hint #2 except this is how mail is typically recieved through email programs (there are other protocols such as IMAP or Exchange for example but this is far simpler to start with).
If you really want to figure out how this works I suggest you make 4 little experiment tools to begin with in this order (from easiest to hardest).
1. Simple SMTP client.
2. Mail Queue lister and deleter.
3. Mail Reader.
4. Mail Reader with MIME support.
Hopefully this has given you a specific direction to work in. If you need more clarification don't hesitate to ask.
Sean Cody (NullStream)
"As long as you want to live,
everywhere will become heaven.
Afterall, you are still alive."
- End Of Evanglion
|
|
|
|
|
I want to use the status bar in my Dialog based app!
but this code doesn't show the status bar!
m_SB.Create(this); // m_SB is a CStatusBar object
m_SB.SetIndicators(indicator, sizeof(indicators)/sizeof(UINT));
I wrote it in OnInitDialog()
but there is no control when my app is running!
Is there more inits to do before a status bar can be shown....? (hope you understod that!
HELP!!!!!!!!!
/*
BETA
*/
|
|
|
|
|
Rickard
I think that you will need to place this function call after the code you have listed above.
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
Also have a look at the project I e-mailed you that shows how to add a menu and statusbar to a dialog based app.
Hope this helps.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Hi,
I want to Lock my system by using the Api LockWorkStation. But Whn I am using that it shows an error undeclared identifier. I already included that winuser.h headerfile in to the program .The OS is Win2000...
Plese Help me
|
|
|
|