|
Thanks a lot!...Redrawwindow() worked.
|
|
|
|
|
Hi,
how do I achieve the following:
I want to right click on a file and go to Open with and select my SDI application and it would be opened in my application the way it gets opened by File | Open etc.
Please advise
|
|
|
|
|
shell extensions
see michael dunn's articles here on cp
they are awesome
"there is no spoon" biz stuff about me
|
|
|
|
|
How can i de style of single cells in the MFC grid so that they convert all input to uppercase.
Change the style of the InPlaceEditControl ??
Luc Devriendt
|
|
|
|
|
Hi, sorry that this might be a beginner question.
I know how to get a pointer form View class to doc class.
But how do you get a pointer from app class to doc class? is there a way? If not can you get a pointer to app class from doc class?
Thanks for your help
Q-Bus
|
|
|
|
|
from the app, I believe you can call GetActiveView() or something.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Do the following:
1.Add a member variable to your app class
CYourDoc* m_pYourDoc;
2.Add a memeber function to your app class:
SetYourDoc(CYourDoc* pYourDoc)
{
m_pYourDoc = pYourDoc;
}
3.In your doc class' constructor call
theApp.SetYourDoc(this);
Peter Molnar
|
|
|
|
|
|
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
|
|
|
|