|
I have a Wizard 97 working great. Only problem is that the button behavior is not as documents. Specifically, the "Back" button is enabled on the First/Welcome page and the "Next" button is not replaced with a "Finish" button on the Last/Completion page.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Already found an answer buried in the documentation.
Every time a page is made active, you receive a WM_NOTIFY message with PSN_SETACTIVE in the code. You then have to send a PSM_SETWIZBUTTONS to the parent with the appropriate flags. How annoying (why didn't they just make the default behavior the expected one and let you override it for the exceptions?)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi.
I'm currently developing a program that uses a pool of worker threads to create network connections. My current model does not work however. I want to have all the network and socket code in a DLL so I can update it as necessary without having to re write the program.
I am looking for the best way to impliment this. Is it best to create say 10 sockets (one for each thread) and have the thread use that socket to connect() with until the pool is empty, or is it better to create a new socket each time the thread is called?
Also what is the best way to impliment non-blocking sockets in this situation? The only reason I am using non-blocking sockets in a worker thread is so that I can set a timeout for connecting and send/recv calls.
I have been having great trouble getting this to work and any thoughts, opinions are welcome however I would greatly appreciate some sample code.
Thanks,
Mike
What I have tried:
The following code is held in a dll. The dll and it's functions are resolved before the thread pool is created. As I create the worker threads they are each given the pointer to these functions (at the moment there is only ServerConnect). I use the pointer to call the functions from the worker threads.
SOCKET* pSocket;
.
.
extern "C" __declspec (dllexport) int ServerConnect (LPCSTR lpServerName, UINT nPort)
{
struct hostent* pHostent;
unsigned int addr;
struct sockaddr_in server;
int nErrorValue;
WSADATA wsaData;
if(WSAStartup(0x101,&wsaData)) {
AfxMessageBox("WSAStartup failed");
return-1;
}
pSocket = new SOCKET;
*pSocket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(*pSocket==INVALID_SOCKET) {
AfxMessageBox("socket failed");
return -1;
}
if(inet_addr(lpServerName)==INADDR_NONE)
pHostent=gethostbyname(lpServerName);
else {
addr=inet_addr(lpServerName);
pHostent=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);
}
if(pHostent==NULL) {
AfxMessageBox("gethostbyname/addr failed");
closesocket(*pSocket);
return -1;
}
server.sin_addr.s_addr=*((unsigned long*)pHostent->h_addr);
server.sin_family=AF_INET;
server.sin_port=htons(nPort);
if(connect(*pSocket,(struct sockaddr*)&server,sizeof(server))==SOCKET_ERROR) {
nErrorValue = WSAGetLastError();
if(nErrorValue==WSAEINVAL)
AfxMessageBox(CString("connect() failed: ") + CString("WSAEINVAL"));
else
AfxMessageBox("connect() failed for another reason");
closesocket(*pSocket);
return -1;
}
return *pSocket;
}
This works fine if I use 1-5 threads, but above that and connect() returns WSAEINVAL.
Any clues anyone?
|
|
|
|
|
One solution is one worker thread and event object to signal a new connection.
Kuphryn
|
|
|
|
|
Hi,
Thanks for answering.
I think that is a good solution for most cases however my program will be handling nothing but a huge load of network traffic. The only way I can see to do this efficiently is with a thread pool.
I realised that most of my trouble is in using new to create a new SOCKET variable. This does not work. I created a variable local to the function and carry it around for each thread - this seems to work ok, but I haven't managed to get this to work fully with non-blocking sockets.
Mike
There are 10 types of people in the world
Those who understand binary, and those who don't
|
|
|
|
|
Hi
I write a Html Editor and I want to get the hole text in a CString. I use CCrytalView. I use for this process
void GetText(const CPoint &ptStart, const CPoint &ptEnd, CString &text);<br />
and I wrote something like this:
CPoint ptSelStart, ptSelEnd; <br />
CRect rect; <br />
<br />
GetClientRect(&rect); <br />
<br />
ptSelStart.x = rect.top; <br />
ptSelStart.y = rect.left; <br />
<br />
ptSelEnd.x = rect.right; <br />
ptSelEnd.y = rect.bottom; <br />
<br />
GetText(m_ptSavedSelStart,m_ptSavedSelEnd,strTemp);
But I always get an Mistake at "GetText()". Why?! Whats is my mistake?!
this works correctly
CPoint ptSelStart, ptSelEnd; <br />
GetSelection(ptSelStart, ptSelEnd); <br />
<br />
GetText(ptSelStart, ptSelEnd, strTemp);
But when I use this, I have always to select the hole text and I dont want that. Can anybody help?!
|
|
|
|
|
Can you tell me where I can find information about GetText() and also about CCrytalView. Is GetText() a Win32 function? How about CCrytalView. I searched in MSDN, I do not find any info. After knowing this, I will try to answer your question.
|
|
|
|
|
Hi !
Just came to thinking it, has anyone else experienced problems with this driver and the latest version of Microsoft Visual Studio ? I am using .NET 2003 Architect version, and if I use the MFC ODBC Consumer wizard to add a predefined datasource to my project, the entire IDE crashes.
The wizard is capable of connecting to the database, allowing me to pick up the tables I wish to use. It crashes after a small delay when I click on 'Finish'.
This is really eluding me, as neither the logs or the debug version of the driver report any problems. It seems to be a Visual Studio -related problem. Any clues ?
The old 2.50 version of the driver worked flawlessly, but it's too outdated for the project
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
This problem seems to be related with the "Bind All" selection of the wizard. Leaving it out will cause the wizard to function flawlessly.
Luckily MSDN is full of articles about dynamic binding, and the usage of RFX.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi,
I want to generate a demo or tutorial for my software
in which a tutorial should do all working of mouse and keyboard automatically i.e. should click on menu item then
when dialog appear it shuld fill it. and click on OK or whatere button.
How to do this stuff programmatically.
Thanx.
|
|
|
|
|
Have a look at the SendInput Windows API function.
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I have an SDI app with CHtmlView as its view. I want to make it full screen, no menus, toolbars or nothing. Similar to internet explorers full screen (F11), but without the toolbar.
How can I do this?
|
|
|
|
|
I dont know how get how many bytes which Sent and Received through by internet connection ?
help me !
|
|
|
|
|
Are you referring to a network monitoring application?
Kuphryn
|
|
|
|
|
is there a shell function to HTML Encode a string? Couldn't find anything sutable in MSDN
(I guess so, so the question is "what's it's name?")
"Vierteile den, der sie Hure schimpft mit einem türkischen Säbel."
mlog || Agile Programming | doxygen
|
|
|
|
|
After posting a similar message a bit before, I did not get a good response so here is what I wrote. If you find something standard, let me know!
<br />
CString MakeXMLProof(const CString & strString) const<br />
{<br />
<br />
CString strResult;<br />
for ( int nRep = 0; nRep < strString.GetLength(); nRep++)<br />
{<br />
TCHAR car = strString[nRep];<br />
if ( car < 256 )<br />
{<br />
switch ( car )<br />
{<br />
case '"':<br />
strResult+=_T(""");<br />
break;<br />
case '<':<br />
strResult+=_T("<");<br />
break;<br />
case '>':<br />
strResult+=_T(">");<br />
break;<br />
case '&':<br />
strResult+=_T("&");<br />
break;<br />
case '\'':<br />
case '\\':<br />
case '%':<br />
case '^':<br />
case '[':<br />
case ']':<br />
case '`':<br />
case '+':<br />
case '$':<br />
case ',':<br />
case '@':<br />
case ';':<br />
case '/':<br />
case '!':<br />
case '#':<br />
case '?':<br />
case '=':<br />
{<br />
CString strBuffer;<br />
strBuffer.Format(_T("&#%d;"),car);<br />
strResult+=strBuffer;<br />
}<br />
break;<br />
default:<br />
strResult+=(char) car;<br />
}<br />
}<br />
else<br />
{<br />
CString strBuffer;<br />
strBuffer.Format(_T("&#%d;"),car);<br />
strResult+=strBuffer;<br />
}<br />
}<br />
<br />
return strResult;<br />
}<br />
<EDIT>By the way, getting the HTML tags not to be interpreted in the post is a nightmare so I hope it makes sense</EDIT>
|
|
|
|
|
(I am using the * to fill in for the &)
I didn't take too much time going through your code, but it looks like you would break HTML that was already formatted. Like if your parser came across "*lt;" (already formatted) it would change it to "*amp;lt;" which would display as "*lt;" instead of "<" :
*lt; = <
*amp;lt = &lt;
|
|
|
|
|
Hi,
I add a Rebar to a SDI (Step 4 of the AppWizard.
in the Resource tab, I add a ComboBox (IDC_cb), when I laungh ClassWizard, it ask me what Class to add, I choose the CMainFrame.
I add a variable (CComboBoxCtrl), then OK.
BUT the variable appears nowhere !?!? omg:
so I laungh ClassWizard again and he ask me the same ???
How can I attach a variable to the ComboBox, and how can I fill it (AddString()) ?
Thanks
Cynicannibal
|
|
|
|
|
Is there any way to hight light or select a whole row in CDataGrid.
Thanks in advance.
Shin
|
|
|
|
|
What happens to the socket connection when you pause a download thread?
What features should you have in your download thread so you can pause & resume the download? Should you just kill the download during pause and restart it when you resume?
Todd Smith
|
|
|
|
|
There are sevearal solutions. Client socket status depends on the server. Some server may disconnect it. Others keep the connection alive.
Kuphryn
|
|
|
|
|
Hi ,
i have a Editbox the contents of which are save to a notepad file.The Edit box is a multiline one and on initialization displays a two line message.I use
str.Format("DATE:\r\n TIME:\r\n");
when I open the notepad file I find the \r being replaced by a new character (somthing like a rectangle).
how to avoid this.
is there any other way to print a multiline message in a edit box without using \r\n?
Thanks
Deepak Samuel.
|
|
|
|
|
Deepak Samuel wrote:
save to a notepad file
I assume you meant text file, as "notepad file" is meaningless. Are you using a CStdioFile object?
Deepak Samuel wrote:
str.Format("DATE:\r\n TIME:\r\n");
As long as the edit control has the ES_MULTILINE style, this will work.
Deepak Samuel wrote:
is there any other way to print a multiline message in a edit box without using \r\n?
No.
When writing to text files, take into account that the newline character (0x0A) is translated to a byte pair (0x0D, 0x0A), and when reading from text files, the byte pair (0x0A, 0x0D) is translated to a single 0x0A byte.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Ola!
I'd like to write an app that logs all requested url's,
but I don't have a clue where to start.
(Microsoft has quite a lot of SDK's / API's, haven't been able to sort out what I need).
Preferrably I'd like to catch something like the http-header including the referrer. (** see edit-note below)
Anyone got any clue / hints in the right direction ?
Edit:
Thinking about it,
it would be even nicer to log *all* requests, not only http.
Ftp, rtsp etc would be sweet too !
|
|
|
|
|
One solution is a network monitor application. Check CodeProject code section.
Kuphryn
|
|
|
|