|
|
Hi! I'm working on a program that opens JPEG images and i'm using GDI+ to do this. Everything was working fine until i tried to create a zoom feature. ScaleTransform() somehow causes horrible flickering. I'm using CMemDC for doulbe buffering which works fine if you view the image at 100% size. Even the scrollbars get sluggish the flickering is so bad. What could be causing this and is there a non-flickering way to do zoom?
-- Steve
|
|
|
|
|
I am not sure this is a GDI+ problem.
Possible causes:
1) failure to over ride CWnd::OnEraseBkgnd() (a.k.a. WM_ERASEBKGND).
2) not drawing the entire client content a memory DC before blitting it to the screen (kind of slow).
When displaying rectangular images that require updating/zooming etc..., I use the following method.
1) Override OnEraseBkgnd() to return TRUE.
2) In OnDraw(): (1) draw the image, (2) then call pDC->ExcludeClipRect() to exclude the drawn image rectangle from furthur drawing, then (3) draw the background (pDC->FillSolidRect(&rectClient, ::GetSysColor(COLOR_WINDOW));).
There are aticles on GDI+ and flicker free drawing at codeproject.
INTP
|
|
|
|
|
Hello,
I want to have more than 1 socket connections to
a port/IP address.
In CAsyncSocket::SetSockOpt(int nOptionName, const void* lpOptionValue,
int nOptionLen, int nLevel = SOL_SOCKET );
What is the value of nOptionName that I should provide for the
function, and how about the lpOptionValue, nOptionLen?
I should call this function before the call to
CAsyncSocket::Create(iPort, SOCK_STREAM, FD_READ | FD_WRITE |
FD_CONNECT | FD_CLOSE, NULL);
or after it.
For now, when I call the Create(), I always get the error code
10048 (WSAEADDRINUSE = Address already in use)
If possible, do you have any short sample to use this to make
connection to the socket that is already in use.
Thanks a lot!Hello,
I want to have more than 1 socket connections to
a port/IP address.
In CAsyncSocket::SetSockOpt(int nOptionName, const void* lpOptionValue,
int nOptionLen, int nLevel = SOL_SOCKET );
What is the value of nOptionName that I should provide for the
function, and how about the lpOptionValue, nOptionLen?
I should call this function before the call to
CAsyncSocket::Create(iPort, SOCK_STREAM, FD_READ | FD_WRITE |
FD_CONNECT | FD_CLOSE, NULL);
or after it.
For now, when I call the Create(), I always get the error code
10048 (WSAEADDRINUSE = Address already in use)
If possible, do you have any short sample to use this to make
connection to the socket that is already in use.
Thanks a lot!
TQD
|
|
|
|
|
A socket can only be created once, so if you or another program has already created it then you will receive the 'in use' error code. A socket can accept multiple connections, once created, and this can be controlled by the parameter given in the 'Accept' function.
|
|
|
|
|
uhhhh -- what are you passing in as iPort?
If you pass in 0, you can create as many connections as you need.
A connection is defined as a source port/ip paired with a destination port/ip. if the source and the destination are reused, you'll get ADDRINUSE.
Passing in 0 as the port (source port) causes the TCP stack to allocate the source port for you... letting you make many.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
plz try to use setsockopt() function with SO_REUSEADDR
SOCKET sock;
BOOL bReuse = TRUE;
....
setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&bReuse,sizeof(int));
...
bind(...);
|
|
|
|
|
How to show a modal dialog in multithread app?
I want to show a modal dialog in multi thread application.
But when I show the dialog as the fllowing, VC shows
"Debug Assertion Failed" dialog. Anyone knows how to
do it? Thanks very much.
CAboutDlg dlg;
dlg.DoModal();
The attachment is a demo.
testmultithread.zip
|
|
|
|
|
Hi LaoWei.
First, there is a little bug in your CreateMultiThread :
void CTestMultiThreadApp::CreateMultiThread()
{
DWORD tID;
g_nIndex[1] = 0;
::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, (LPVOID)&(g_nIndex[0]), 0, &tID);
g_nIndex[1] = 1;
::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, (LPVOID)&(g_nIndex[1]), 0, &tID);
} Second, you use CreateThread in conjunction with MFC. This is dangerous. If your thread uses MFC support it should always be created via AfxBeginThread . Knowing this, you can write CreateMultiThread as follows:
void CTestMultiThreadApp::CreateMultiThread()
{
DWORD tID;
g_nIndex[0] = 0;
AfxBeginThread((AFX_THREADPROC)afxThreadProc,(LPVOID)&(g_nIndex[0]));
g_nIndex[1] = 1;
AfxBeginThread((AFX_THREADPROC)afxThreadProc,(LPVOID)&(g_nIndex[1]));
} Now your "Debug Assertion Failed" is gone bye bye...
RK
|
|
|
|
|
How does one go about getting the number of files in a directory with VC++?
Thanks for any help.
|
|
|
|
|
|
Thanks for your reply; but it only finds files not give you a total file count in a dir.
|
|
|
|
|
Here's an example using MFC CFileFind.
<br />
#include <afx.h><br />
<br />
void main()<br />
{<br />
CFileFind find;<br />
BOOL notdone = find.FindFile("E:\\test\\*.*");<br />
int files = 0;<br />
int directories = 0;<br />
<br />
if (!notdone)<br />
printf("No files found\n");<br />
<br />
while (notdone)<br />
{<br />
notdone = find.FindNextFile();<br />
<br />
if (find.IsDots())<br />
continue;<br />
<br />
if (find.IsDirectory())<br />
directories++;<br />
else<br />
files++;<br />
}<br />
find.Close();<br />
printf("Files:\t%d\n", files);<br />
printf("Directories:\t%d\n", directories);<br />
}
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
|
Thank you for the code example. Is there a API that supplies us with the file count in a directory?
|
|
|
|
|
Haven't used this, but this might be what your looking for:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiodirectoryclassgetfilestopic2.asp[^]
specifically this section:
<br />
[C++] <br />
#using <mscorlib.dll><br />
<br />
using namespace System;<br />
using namespace System::IO;<br />
<br />
int main() {<br />
try {<br />
String* dirs[] = Directory::GetFiles(S"c:\\", S"c*");<br />
Console::WriteLine(S"The number of files starting with c is {0}.", __box(dirs->Length));<br />
Collections::IEnumerator* myEnum = dirs->GetEnumerator();<br />
while (myEnum->MoveNext()) {<br />
Console::WriteLine(myEnum->Current);<br />
}<br />
} catch (Exception* e) {<br />
Console::WriteLine(S"The process failed: {0}", e);<br />
}<br />
}<br />
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
|
I'm having trouble using a CSliderCtrl. I'm trying to set the range from 0 -> 16384 by calling: m_sliderZoom.SetRange(0, 16384, FALSE); in the OnInitDialog() func.
Two strange things are happening. First, if I immediately call GetRange() on the control, it returns both min and max values as 0. Secondly, when I call GetRange() later in the code, the range is always from 0 -> 100.
So, why doesn't GetRange() at least return 0 -> 100 immediately after setting the range? And, more importantly, why am I unable to change the range from 0 -> 100? I've tried setting it to 0 -> 25, as well, with no difference in the final range.
Any help is greatly appreciated.
Here's what I think is the relevant code:
BOOL CSMRLocatorDlg::OnInitDialog()
{
// other stuff
m_sliderZoom.SetRange(0, 16384, FALSE);
int min;
int max;
m_sliderZoom.GetRange( min, max );
CString message;
message.Format( "Min: %d Max: %d", min, max );
AfxMessageBox( message );
// always "Min: 0 Max: 0"
// other stuff
}
// later in the code
void CSMRLocatorDlg::OnOut()
{
m_nZoomLevel = m_sliderZoom.GetPos();
CString message;
int min;
int max;
m_sliderZoom.GetRange( min, max );
message.Format( "Min: %d Max: %d", min, max );
AfxMessageBox( message );
// always "Min: 0 Max: 100"
}
|
|
|
|
|
OK. I figured it out and I'm feeling very stupid right now. The base version of CDialog::OnInitDialog() was being called, but not until after I was trying to SetRange() and GetRange(). This explains the bogus results of GetRange() and the fact that my desired range had no effect. I can offer as an excuse the fact that I was handed this code after somebody else wrote it
I am still wondering how this code worked before, though. According to the previous developer, he had no problems setting the range, even with the call coming before CDialog::OnInitDialog(). Does anyone know if different platforms or versions of MFC DLLs or something else could have allowed the code to work this way?
Thanks.
|
|
|
|
|
Hi,
I have a mysql database on a Redhat linux system.I want to access that database using VC++ as the front end.How should I do?Can someone provide a sample example code for this.
Karteek
|
|
|
|
|
|
just use odbc
there is an odbc driver for mysql on their website
"there is no spoon" biz stuff about me
|
|
|
|
|
Hi,
Thanks a lot.
But still I have a problem.I got the ODBC driver and created a DSN and wrote a sample WIN32 Console appln to test it .But it is not working.Please check this code.
#include "stdafx.h"
#include<afx.h>
#include<afxdb.h>
int main(int argc, char* argv[])
{
printf("Hello World!\n");
CDatabase c;
c.Open(_T("test"),FALSE,FALSE,_T("ODBC"),TRUE);
return 0;
}
It is giving the following errors.
--------------------Configuration: kardb - Win32 Debug--------------------
Compiling...
kardb.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/kardb.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
kardb.exe - 3 error(s), 0 warning(s)
|
|
|
|
|
Hello guys,
do you know if it is possible to get a file name from a file handle?
I tried the code below and strFileName its empty. I've tried to find some info into the MSDN and I cannot manage to find out a method that take in input the file handle and gives me back the file name.
Thanx,
Fabio
CFile* file = new CFile(_T("C:\\test.txt"), CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone);
CFile newFile((int) file->m_hFile);
newFile.Write("C", 1);
strFileName = newFile.GetFilePath();
file->Close();
|
|
|
|
|
i know that there is a way in kernel mode... but i don't know if it is exported
to user mode.
Don't try it, just do it!
|
|
|
|
|
Highly coupled code is code where the dependencies between things are dense, lots of things depend on other things.
On Unix i know makedepend can give u the dependecies of your classes.
Do any of you have experience in such tool under windows? (better to be opensource)
Thanks and regards,
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I do not know if this helps, but Visual C++ comes with Depends that will tell you what you application depends on. There is also an add on that you can get (may be open source) called BeSweet. You can also use Doxygen to genterate documentation for your project, I beleive it will show all the dependencies in your project (read the article on Doxygen at codeproject).
INTP
|
|
|
|
|