|
|
The question is straight: any ideas how i can set the client area of an mfc dialog?
|
|
|
|
|
You can use MoveWindow[^] any time after the base class' OnInitDialog has been called.
Bob Ciora
|
|
|
|
|
There's also SetWindowPos() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Dear Friends,
This question is related to MS-Word automation. I want to find some statistics related to the opened word document. I've already found two statistics like count of total words and count of total characters using various word-automation interfaces.
I found some statistics indirectly, for example i wanted to calculate total number of characters in Bold in my document. There is no such support directly provided in MS-Word and automation functions. However i used "Find Dialog Box" and WildCharacters property to get the total count of these characters.
So far so good. Now i want to find some other statistics but i am struggling to find out and i require your help. I want to find the total number of:
--Bullets in my document
--Fonts used in my document
--Font sizes used in my document
Can anyone tell me that how can i computee these values via directly using Word or by automation.
Ahsan
Ahsan
|
|
|
|
|
How Can I change the background color of a toolbar at runtime. Any idea, I have added a new button to CFileDialog Control, now I want to change its back color of the toolbar. Any help. Also How can I get the handle of the buttons in Toolbar ?
Regards
|
|
|
|
|
Hi, how can i draw an icon next to the edit control in a combo box? Ive successfully managed to draw a list icons in the listbox, but now i want to draw the icon that the user selected next to the text in the edit box.
Ive obtained the edit box by attaching to it in the OnCtlColor() message of the combo box.
Thanks
Skute
|
|
|
|
|
Hi!
I have written a small system-wide hook dll in vc++ 6, I would like to generate from the Ctrl key an ALT key.
HOW can I from a wm_keydown message a WM_SYSKEYDOWN message generate?
Because the alt key is a special key..
if the ctrl was pressed down -> in the spy the wm_syskeydown msg. to be seen,
if ctrl is repeated ->wm_syskeydown,
if ctrl is released -> wm_syskeyup to be seen
AND the Ctrl+A to became an Alt+A event.
Thanks in advance!!
|
|
|
|
|
Hi all
I am making a tool to monitor system's hardwares, softwares and internet activities by user.
In this way I have completed Software & hardware portion now I have been stucked in Internet activities part.
So please anybody can tell me that How can I monitor Emails sent & recieved, Files downloaded.
Better if provide some samples to do this.
Thanks & Regards
|
|
|
|
|
rajeevktripathi wrote:
So please anybody can tell me that How can I monitor Emails sent & recieved, Files downloaded.
I would think you'd need to monitor ports 25 (SMTP), 110 (POP3), 80 (HTTP), and 21 (FTP). These are default values for a particular service, however. I know there is a way to find out which port is associated with a particular service but the name escapes me.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
rajeevktripathi wrote:
How can I monitor Emails sent & recieved, Files downloaded.
LSP dll can help in this case :-
LSP DLL[^]
|
|
|
|
|
<br />
DWORD WINAPI tredu (LPVOID lpParam );<br />
<br />
<br />
int APIENTRY WinMain(HINSTANCE a,HINSTANCE b,LPSTR <br />
<br />
comanda,int arata)<br />
{<br />
<br />
HANDLE hThread;<br />
DWORD dwID,dwThrdParam = 1;<br />
hThread = CreateThread (NULL, 0,tredu ,&dwThrdParam, <br />
<br />
0, &dwID);<br />
if (hThread==NULL)<br />
MessageBox(0,"a","a",MB_OK);<br />
<br />
return 0;<br />
}<br />
<br />
DWORD WINAPI tredu (LPVOID lpParam )<br />
{<br />
Beep(1000,1000);<br />
MessageBox(0,"a","b",MB_OK);<br />
return 0;<br />
}<br />
<br />
this does nothing?
where am I going wrong
the handle is not NULL but nothing happens
I am using VC 7.0
|
|
|
|
|
Your main thread exits as soon as it has created the second thread, so probably it destroys the second thread.
|
|
|
|
|
The main thread ends too soon. Try:
if (hThread==NULL)
MessageBox(0,"a","a",MB_OK);
else
MessageBox(0,"b","a",MB_OK);
"tous les sifflets des trains, toutes les sirènes des bateaux
m'ont chanté cent fois la chanson de l'Eldorado"
rechi+
|
|
|
|
|
It works fine in VC6. I can't test in VC7 ...
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
As mentioned, the main is exiting before the thread can even execute. To wait for the thread to terminate, you can do a WaitForSingleObject(hThread, INFINITE); . This will wait for the thread handle to become "invalid," which occurs when the thread terminates. At that point, you should also do a CloseHandle(hThread); before exiting.
Bob Ciora
|
|
|
|
|
I agree with cedric. I recommend you look into events, they help control synchronization between the thread and your app.
Here's what I'd usually do:
struct threadPkg {<br />
HANDLE hStartup, hStopNow, hShutdown;<br />
};<br />
<br />
UINT ThreadFunc (LPVOID lpParam) {<br />
threadPkg * pkg = (threadPkg *) lpParam;<br />
::SetEvent(pkg->hStartup);<br />
<br />
while (true) {<br />
switch (::WaitForSingleObject(pkg->hStopNow, 10)) {<br />
case WAIT_OBJECT_0: {<br />
::SetEvent(pkg->hShutdown);<br />
AfxEndThread(0, true);<br />
return 0;<br />
} break;<br />
case WAIT_TIMEOUT: {<br />
} break;<br />
}<br />
}<br />
}<br />
<br />
bool StartThread (threadPkg * pkg) {<br />
CWinThread * thread = AfxBeginThread(ThreadFunc, pkg, THREAD_PRIORITY_IDLE, 0, 0, NULL);<br />
<br />
switch (::WaitForSingleObject(pkg->hStartup, INFINITE)) {<br />
case WAIT_OBJECT_0: { return true; } break;<br />
case WAIT_TIMEOUT: {
return false;
} break;<br />
}<br />
}<br />
<br />
void StopThread (threadPkg * pkg) {<br />
::SetEvent(pkg->hStopNow);<br />
switch (::WaitForSingleEvent(pkg->hShutdown, INFINITE)) {<br />
case WAIT_OBJECT_0: break;<br />
}<br />
}<br />
<br />
void main () {<br />
threadPkg * pkg = new threadPkg;<br />
pkg->hStartup = ::CreateEvent(NULL, true, false, "startup sequence, thread->main");<br />
pkg->hStopNow = ::CreateEvent(NULL, true, false, "signal to stop now, main->thread");<br />
pkg->hShutdown = ::CreateEvent(NULL, true, false, "thread has shut down, thread->main");<br />
<br />
if (StartThread(pkg)) {<br />
StopThread(pkg);<br />
} else {<br />
MessageBox(NULL, "Error: The worker thread was not started.", "Critical Error", MB_OK);<br />
}<br />
}
What that will do is begin a handshaking process when you start up the thread. This function creates 3 events and do what the text description says. It creates the thread, then waits for the thread to tell it that it has started and is on it's feet. You can do what you want and the thread will continue working, occaisionally asking if it's been told to quit. When you are ready to stop the thread, the function is called and it sends the hStopNow singal, the thread catches it, quits nicely and simultaneously signals back it's received and has shutdown. This is the basic organization of my threads I use all the time. Of course, what happens in main depends on what you want, you can put the start and end thread functions however you need them.
Note: I just wrote that off the cuff, I haven't tested that exact code but it looks correct in it's entirety.
Good Luck
|
|
|
|
|
Sometimes I wonder whether I need a C++ geek or a shrink to solve my coding problems...
(info: I am using Visual Studio .NET 2003 7.1.3008 on Windows XP Pro SP 2)
With the project wizard of my Visual Studio I made an MFC application with multiple documents (MDI). I assigned a file type to my project: .nix (my .nix files are plain text files). In addition to the now automatically created code I added in the Doc an OnOpenDocument reading the first five lines of the openend file, storing them in a list of std::strings. I even added in the View in OnDraw a simple routine that prints those list of stings from the Doc straight to the pDC with TextOut. So far, nothing spectacular.
Problem #1
After starting the application the very first time my file type associations get registered. Afterwards my .nix files have the default icon of my application and are even named correctly. Now when I double-click those files in the Windows Explorer my application starts BUT the .nix file is never read and no document is opened. I can open those files manually with "File" -> "Open..." with my application but the double-click on the file itself never ever works.
Problem #2
When I start my application by double-clicking the .exe everything is fine. But when I start the application by double-clicking an associated file .nix (next to my problem #1) there is a very strange effect: when I simply close the application again the function CWinApp::ExitInstance throws an exception in line 661 of appcore.cpp because CWinapp::m_pCmdInfo has a value of 0x00000001 which obviously is a pointer no nowhere (and having a pointer address of exactly 1 is like winning the lottery, right?!).
As I said, next to my trivial code additions described above this all comes from MFC source files or automatically generated code by the project wizard. It's hard to believe that this code is so bad that it could go so horribly wrong.
I guess a huge amount of other people make MFC MDI applications with associated file types so all those other people should suffer from those problems, too, shouldn't they?! Or is it a problem only for me?! On the other hand I do have the same behaviour of my application on other PCs.
Help needed... (at least moral support...)
Bye,
Matthias
P.S.: my little example project can be found here
-- modified at 4:38 Wednesday 7th September, 2005
|
|
|
|
|
If I don't want the length of the string to be sent but I just want the sting that I type send to server. How to I change the code? Bytesend to strsend? how to change the lstrlen?
// Send and receive data.
long bytesSent;
long bytesRecv = SOCKET_ERROR;
char sendbuf[300] = "Client: Sending data.";
char recvbuf[300] = "";
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 );
printf( "Bytes Sent: %ld\n", bytesSent );
while( bytesRecv == SOCKET_ERROR )
{
bytesRecv = recv( m_socket, recvbuf, 300, 0 );
if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET )
{
printf( "Connection Closed.\n");
break;
}
if (bytesRecv < 0)
return;
printf( "Bytes Recv: %ld\n", bytesRecv );
}
return;
|
|
|
|
|
What's your problem ? For me, this code looks fine (except that I don't know what send, recv, ... do).
Your send function needs to know how many bytes to send so you have to specify the number of bytes in your string.
Is there a problem with that?
|
|
|
|
|
The code don't have any problem. After I compile, it will show bytesrecv: 21 which is the length of the string. I don't want the length of the string to print out but is the string itself print out. how do I program it?
|
|
|
|
|
Replace:
if (bytesRecv < 0)<br />
return;<br />
printf( "Bytes Recv: %ld\n", bytesRecv );<br />
}<br />
by:
if (bytesRecv < 0)<br />
return;<br />
printf( "String Recv: %s\n", recvbuf);<br />
}<br />
|
|
|
|
|
Its work! How do I change it so that I can type on the dos and send it. The code now is when I type what I want to send in this:
char sendbuf[300] = " ";
and after I compile, it will automatically send to the server. But what I want is when I compile it, I can type on it and then send it to the server.
|
|
|
|
|
It's possible that you have a problem with this line:
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 );
Since you use the length of sendbuf, you won't transmit the terminating NULL-byte of sendbuf.
This could present a problem in the receiving end.
If you wan't the original data (a char array) in you have got two options:
1.
Send the terminating NULL-character by doing this:
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf) + 1, 0 );
2.
At the receiving end, add a '\0' in the receive buffer at offset <noofreceivedbytes>. For instance:
bytesRecv = recv( m_socket, recvbuf, 300, 0 );
recvbuf[bytesRecv] = '\0';
Else, the code looks fine to me.
|
|
|
|
|
Hi
anyone have any idea on how to insert page number into ms word doc. I have an application that creates a report, now I need to include the page number as well.
I tried HeaderFooter class and PageNumbers class but ends up with illegal operation msg. Anyone have any idea?
Thanks in advance.
Thomas
|
|
|
|
|