|
Consider a global thread function. Otherwise, make run() a static function.
Kuphryn
|
|
|
|
|
If I make run() static.. how can I access member functions from CMainFrame? Or is that a "no-no"?
|
|
|
|
|
You may access the static member function via :: operator.
Kuphryn
|
|
|
|
|
This looks ok to me and is the sort of thing I do in ED. I wouldn't have called both functions run though, but that is besides the point. Also don't use the old C style casts in C++. I assume the view exists for the duration of the thread function. Where precisely does it crash?
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
it crashes on the Create() of the CSocket object.. I just implemented a CWinThread class and I am trying to do the same thing with in that class because someone stated that I need a UI thread instead of a worker thread.. I guess CSocket needs a Message Pump.. but now I am still having the same problems it still crashes on the Create function.. I posted another question in the forum because I changed the code so much.. I have a feeling that the CSocket needs to be attached to the thread but I am having no luck.. Any ideas?
|
|
|
|
|
I'm afraid I can't help much with CSocket as I've never used it. That said if you look in the debugger at the error it should give you a very good idea of what the problem is. Looking at the MFC code my guess is something in CAsyncSocket::AttachHandle() is ASSERTing.
I'd be surprised if there wasn't code which used CSocket in a thread here on CP. Maybe spend some time looking at the articles in the relevant section.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Thanks for all the suggestions.. I am going to trace the error codes for CSOcket and see what type of error i am getting from the create function.. I tried to create the socket in my main thread and pass the handle to the thread but the socket in the thread gives me a invalid socket.. anyway, I'll do some more testing, its probably just something dumb on my part..
Thanks!
Rob
|
|
|
|
|
// setowner.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <windows.h>
#include <tchar.h>
#define ErrorHandler(s) _ErrorHandler(s, __FILE__, __LINE__)
void _ErrorHandler(LPCSTR lpszLocation, LPCTSTR lpszSrcFile, UINT nSrcLine)
{
LPVOID lpMsgBuf;
DWORD dwError = GetLastError();
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPSTR) &lpMsgBuf,
0,
NULL );
// Process any inserts in lpMsgBuf.
cout<<"ERROR @ "<
|
|
|
|
|
ive seen a lot of application create .exe from the main application, and not just one, i mean after a serie of choices u can do that.
To make myself clear, im not talking about adding a single exe to the ressource and reading it than writing it in a .exe file.
I meant after a series of tests or choices i want to be able to generate a custom .exe
Hope this is clear enough, and thanks in advance for any tip or help!
Johnny
|
|
|
|
|
See this[^] for informations about PE file format (Win32 exe).
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks a lot, ill read through it!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hello,
I am using a function called IDiscMaster::GetPath(). This function is returning the OS path like for CDRom its \Device\CDRom0. How can I find out that this path is mapping to which drive. Like I want to findout whether this \Device\CdRom0, is mapping to drive A:\,B ... so on.
Please, help if someone has any idea.
Thanks,
|
|
|
|
|
QueryDosDevice. Though, I think you can only use a drive letter to get an NT object name, meaning you'll have to loop all drive-letters until you find a match.
|
|
|
|
|
I want to receive some bitmap from client with socket. How i can start?
|
|
|
|
|
Start developping the Client server first, then u can just read the bitmpap file and send it to the server and its the job of the server to rewrite the bitmap file !
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
This is answered in this forum before, you can try search the forum!
But, to send a bitmap you just read the bitmap file in binary mode and then simply send(bitmap_data,...) !
or something!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hi!
I'm using the Win NT UpdateResource API to change the main icon of a program. My code works well if I extract an icon from a module (EXE/DLL) and I replace the destination icon by this one.
Here my code:
<br />
HANDLE hUpdate;<br />
char* lpResLock;<br />
HINSTANCE hExe;<br />
HRSRC hRess;<br />
<br />
hExe=LoadLibrary ("c:\\winnt\\explorer.exe");<br />
hRess=FindResource (hExe, MAKEINTRESOURCE (10), RT_ICON);<br />
lpResLock=(char*) LockResource (LoadResource (hExe, hRess));<br />
<br />
hUpdate=BeginUpdateResource ("c:\\winnt\\calc.exe", FALSE);<br />
UpdateResource (hUpdate, RT_ICON, MAKEINTRESOURCE (1), 1036, lpResLock,SizeofResource(hExe, hRess));<br />
EndUpdateResource (hUpdate, FALSE);<br />
FreeLibrary (hExe);<br />
I would now like to do the same thing but instead of extracting an icon from an module, I would like to get the icon from an ICO file.
How can I use UpdateResource API with an ICO file?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
|
|
Hi,
If I create a tempfile with _open (_sopen) and _O_TEMPORARY-flag I can write to this file but I hav'nt access from an other application. Here the complete Code:
int fh = _sopen ("tempfile.ext", _O_BINARY | _O_RDWR | _O_CREAT | _O_TEMPORARY, _SH_DENYNO, _S_IREAD | _S_IWRITE);
int written = _write (fh, (void *) buffer, sizeof (buffer));
StartApplication ("tempfile.exe");
_close (fh);
Is anybody out there with an solution? I hoped, if I close my 2nd Application (he should open the tempfile for read), the system delete my tempfile automaticly.
Stephan
|
|
|
|
|
I have a code statements:
vect<cstring> strs("ddd");
find(strs.begin(), strs.end(), strs);
Building message:
error C2440: '=' : cannot convert from 'const class CString *' to 'class CString *'
|
|
|
|
|
1. what is a "vect" ?
2. what line does the error message refer to?
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Chris Losinger wrote:
1. what is a "vect" ?
Chris,
It looks like he migh have done something like this, maybe??:
typedef vector<CString> vect;
error C2440: '=' : cannot convert from 'const class CString *' to 'class CString *'
Could you be having a problem with a copy constructor or do you not have to deal with those when working with the CString 's?
Nick Parker
The greatest lesson in life is to know that even fools are right sometimes. - Winston Churchill
|
|
|
|
|
try
find(strs.begin(), strs.end(), CString("ddd"));
Todd Smith
|
|
|
|
|
Can anyone tell me how to programatically delete the file. Can this be achieved via CFile ???
|
|
|
|