|
yes the function is defined bymyself and it is not part of a library and i cant post the whole source code coz im not in home il get friday night or saturday to home then well see about that greeetz for helping me and if u wanna please add me my msn is ivor99@hotmail.com then we could talk .
|
|
|
|
|
I was wondering how do I get text out of a textbox and use that as the filename? I'm making a program that keeps track of people and want to have their username as the file name, so each user has his/her own file.
|
|
|
|
|
try EM_GETLINE or WM_GETTEXT
|
|
|
|
|
stream = freopen( this->textBox1->Text, "w", stderr );
thats the line I tried, where would I put that?
|
|
|
|
|
im making a program that will list all the files in several dir. they all list except the Temporary Internet Files dir. and i know as of now there is 951 files any one know why it wont and how to make it list them to?
|
|
|
|
|
use
SHGetSpecialFolderPath()
clsid of "Temporary Internet Files" is
CSIDL_INTERNET_CACHE
after getting the path
you can use
FindFirstFile ()
FindNextFile()
I will help
|
|
|
|
|
use
SHGetSpecialFolderPath()
clsid of "Temporary Internet Files" is
CSIDL_INTERNET_CACHE
after getting the path <--- i made it that far but the rest is a weeeeee bit over my headand there is a catch its not just 1 dir. there is 3 of them on my pc
C:\\Documents and Settings\\jack\\Local Settings\\Temporary Internet Files
C:\\Documents and Settings\\Administrator\\Local Settings\\Temporary Internet Files
C:\\Documents and Settings\\Default User\\Local Settings\\Temporary Internet Files
i want to scan all 3 but i can only get the path to the first one.
|
|
|
|
|
Hi,
You can use API from Wininet:
FindFirstUrlCacheEntry
FindNextUrlCacheEntry
FindCloseUrlCache
-----------
Mila
|
|
|
|
|
Hi all,
Who can help me for my below question? I will appriciate that.
In my MFC project, I used RichEdit replacing RichEdit2, but the color of the text are shifted one unit.
My code:
CString strings[3] = {_T("Apple"), _T("Orange"), _T("Pear")};
for (int i = 0; i < 3; i ++)
{
CHARFORMAT2 cf;
m_richEditCtrl.GetSelectionCharFormat(cf);
if ( i % 2 == 0 )
{
cf.crTextColor = (DWORD) RGB(255, 0 , 0); // Red color
}
else
{
cf.crTextColor = (DWORD) RGB(0, 0, 225); // Blue color
}
cf.dwEffects = static_cast<dword>(~CFE_AUTOCOLOR);
cf.dwMask = CFM_COLOR;
long length = m_richEditCtrl.GetTextLength();
m_richEditCtrl.SetSel(length, -1);
m_richEditCtrl.ReplaceSel(strings[i]);
long newLength = m_richEditCtrl.GetTextLength();
m_richEditCtrl.SetSel(length, newLength );
m_richEditCtrl.SetSelectionCharFormat(cf);
}
When I used RichEdit1 the program works perfect, but after I used RichEdit2 the color of text shows weird.
Accordding to the code, "Apple" should show red color, "Orange" should show blue color, "Pear" should show red color again. However, the actual text color are: letters "Apple" are red, "O" is red too, "range pe" are blue , and "ar" are red. That doesn't make any sense....
Is there anyone can help me on that?
Thanks!
David Zuo
|
|
|
|
|
Should this line
m_richEditCtrl.SetSel(length, newLength );
be
m_richEditCtrl.SetSel(length, newLength - 1 );
??
|
|
|
|
|
I tried m_richEditCtrl.SetSel(length, newLength - 1 ), but it still doesn't work well. Actually, what I found is RichEdit2 considers '\n' as two symbols - "\r\n", so if we use
m_richEditCtrl.SetWindowText("12345\n");
int length = richEditCtrl.GetWindowText(); // the actual value of length equals to 7, not 6.
Again, if we have
m_richEditCtrl.SetWindowText("12345\n67890");
int length = richEditCtrl.GetWindowText(); // equals to 12, not 11.
richEditCtrl.SetSel(0, 6);
m_richEditCtrl.SetSelColor(Red); // pseudo-code
m_richEditCtrl.SetSel(7, -1); // This function doesn't set correct text
m_richEditCtrl.SetSelColor(Blue); // pseudo-code
/// The actual text color is, "123456" is red, "7890" is blue
/// If you put more letters and '\n' into the string, you will find the text color shifts more than you think
but, if we use
m_richEditCtrl.SetWindowText("12345\n67890");
int length = richEditCtrl.GetWindowText(); // equals to 12, not 11.
richEditCtrl.SetSel(0, 5);
m_richEditCtrl.SetSelColor(Red); // pseudo-code
m_richEditCtrl.SetSel(6, -1);
m_richEditCtrl.SetSelColor(Blue); // pseudo-code
/// program now works well
What I found is, the number of the selected text SetSel() function shifts that equals to the number of '\n' being used in the string. Is it weird?
Most time I cann't understand why Microsoft still recommand us to use Visual C++, MFC is too old to use. They always use very weird way to do some crazy things. Doesn't make any sense! Furthermore, so manys bugs are found in MFC library, it seems Microsoft never tested their APIs before they released them.
David Zuo
|
|
|
|
|
Glad you got it working. I never saw any newlines (\n) in your original code
David.YueZuo wrote: Furthermore, so manys bugs are found in MFC library, it seems Microsoft never tested their APIs before they released them.
Wow what MFC version are you using? MFC works as documented for me (Version 7.11).
David.YueZuo wrote: MFC is too old to use
So use .NET! Better yet, use Windows APIs directly!
I didn't know Microsoft "recommand us to use Visual C++" either.
This is all news to me, thanks!
Mark
|
|
|
|
|
LOL..thx for your suggestions, i will keep that in my mind.
Unfortunately, my team have to use VC++ since they started using it at 1998.
Maybe I should get my job changed, how about become to a java developer, would be better?
hahaha...
David Zuo
|
|
|
|
|
Hi all,
Using VC++ 6 with MFC.
What I'm trying to do is have a secondary modeless dialog which can be attached to the main dialog and detached again, similar to winamp. The way I'm thinking of implementing this is having two dialog classes for the main and modeless dialogs, and one dialog resource with the actual controls etc (child, no title bar etc.), similar to the way you use a CTabCtrl.
I want the 'Screen' dialog resource to be loaded into either the secondary or primary dialog based on user input, possibly by replacing a static control?
How can I implement this?
Thanks
Bob
|
|
|
|
|
Some helpful APIs for this are
ShowWindow() to hide/show windows/dialogs
MoveWindow() to resize/reposition child windows
GetWindowRect() to get a window's position relative to screen
MapWindowPoints() to translate screen coordinates to parent-window-relative coordinates
SetParent() to "move" a child window between parents
Using an invisible (no WS_VISIBLE style) static control is an easy way to find the rect for
positioning a child window on a dialog.
Mark
|
|
|
|
|
Im not sure its helpful for you or no but you can see an example of david crow about resources
|
|
|
|
|
Hi,
I have a cdialog window which contains a webbrowser activex control. I want to be able to select some text from a control on the dialog (but not inside the webbrowser), and drag it into a textarea element within the webbrowser control. How do I do this? Can someone point me in the right direction?
Thanks,
derek
|
|
|
|
|
Hi there,
I have an application that uses TCP/IP socket connection to another application and I was wondering how I can check if the connection is up or not in the other word I need to notify a 3rd application if the connection between the first two has droped for any reasons. I tested today that if I am connecting to the second application that sits in another computer and I turn off the wireless connection button on the second computer so that the connection would be dropped, when I run the netstat command in dos command window, it shows that the connection is still up and my application does not recognises that the connection is actually dropped until I physically close the second application.
Could any one inform me that how these things work and how can I make my application underestands that the connection between the sockets is dropped do to wireless or network problem and so on?
I really appreciate any suggestions.
Best reagards,
Nahi
|
|
|
|
|
What state is the connection in (according to netstat)? CLOSE_WAIT?
When the connection drops, recv() will either return 0 or SOCKET_ERROR (WSAGetLastError() will get
the error code) - I can't remember which right off hand (brain in screen-saver mode). Either
way, when you get an error on send() or recv() you can notify the 3rd application that the
connection dropped. A breakpoint right after a recv() call will show you which occurs when you
switch off the connection.
Lost connections will linger (you'll see them in netstat) until you officially close the socket or the
application. Therefore, when you detect the network down you should close the socket when unrecoverable
error codes are returned (they are listed in the send()/recv() API specs).
Hope this helps a little
Mark
|
|
|
|
|
Thanks for the tip, as I mentioned before when I disconnect the wireless network of the computer so that the connection ids dropped, netstat still shows that the connection is stablished!? until I close one of the application. and as my application should receive messages from the other application through the socket, I do not understand that the connection is down. Only when IN close the second application, I get the socket closed message and in netstat I can see close_wait.
Thanks,
|
|
|
|
|
Yes, you'll see the connection in netstat because the socket is still allocated even though it
may be disconnected physically. It will remain in CLOSE_WAIT (waiting for close as the name
implies) until you call closesocket(). Even after calling closesocket(), if there is/was pending
data on the connection it will "linger" by default for I think 120 seconds (so you'll see it in
netstat for that long). To force it to close immediately you can turn off the linger option for
the socket, something like:
linger Linger;
Linger.l_onoff = 1;
Linger.l_linger = 0;
::setsockopt(hSocket, SOL_SOCKET, SO_LINGER, (const char *)&Linger, sizeof(linger));
::closesocket(hSocket);
hSocket = INVALID_SOCKET;
|
|
|
|
|
Send a ping packet to the other IP address. If it doesnt come back, youknow the link is dead.
Truth is the subjection of reality to an individuals perception
|
|
|
|
|
You could wait until the TCP/IP stack reports that the connection is down (can take very long). Alternatively send a small connection testing packet (e.g. smilar to IRC's PING/PONG mechnism), sometimes you will receive immediately an error saying that the connection is down... or you can timeout the connection if you haven't received a connection test packets from the other peer for a while.
[corrected typos]
|
|
|
|
|
Why does the mousewheel event not scroll the window in a CRichEditView?
Mark
|
|
|
|
|
CRichEditView class doesn't handle the WM_MOUSEWHEEL event.
You can derive a class from CRichEditView and handle it yourself.
Mark
|
|
|
|