|
Why do humanbeings have confusing identity
OwnerDrawn(not you)
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi,
Use GDI+ to draw the bitmaps.
Make the list box owner drawn.
Create a Graphics object and initialise with the listbox DC.
Create an Image object and using Graphics::DrawImage draw the image in the required cell.
Image and Graphics are GDI+ classes.
Thanks and Regards,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Thank you for your answer!
I need to read the bitmap files from a predefined folder.
I would like to know that I do need to use CImageList or not?
Please help!
|
|
|
|
|
Hi,
Check this[^]
Thanks and Regards,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
I had checked it.
I found that he use CImageList.
I would like to know how to use CImageList with ListBox?
What is the concept of it?
Please help!
|
|
|
|
|
Hi there, Iv wrote a program to transfer files between a cleint and a server,the code works fine for small files but not for large files,im going to post the code wich i hope will help other people trying to do something similar and in hope that i can get some suggestions on how to improve the code iv wrote.
<server>
{
char *buffer;
char sizebuf[20] = "";
long SizeOfFile = 1;
long BytesSent = 0;
std::ifstream file ("C:\\Windows\\Example.exe" std::ios::in | std::ios::binary | std::ios::ate);
if (!file)
{
MessageBox(NULL,"Error Opening File",NULL,MB_OK);
}
SizeOfFile = file.tellg(); //get size of file
file.seekg (0, std::ios::beg);
ltoa(SizeOfFile,sizebuf,10); //put sizeoffile in char buf
send(newsock,sizebuf,strlen(sizebuf),0);//send the size to client
buffer = new char[SizeOfFile];
file.read (buffer,SizeOfFile).eof();
do{
BytesSent = send(newsock,buffer,SizeOfFile,0);
}while(BytesSent < SizeOfFile);
Here i dont know if i should be reading blocks of the file into the buffer in the do while loop or out side of the loop and i dont know how to equally divide the file into "Chunks" to be sent separatly and rebuilt the other side help would be appriciated
<client><mfc>
{
char buffer[20];
long SizeOfFile = 0;
char* recvfilebuf;
recv(Socket,buffer,sizeof(buffer),0); //recv size of file to be d/l
SizeOfFile = atol(buffer);
ZeroMemory(buffer,20);
recvfileBuf = new char[SizeOfFile];
std::fstream file (C:\\Example.exe, std::ios::out | std::ios::binary | std::ios::ate); //Dir of our new .exe
if (!file)
{
MessageBox(NULL,"Error Opening File",MB_OK);
}
do
{
recieved = recv(Socket,recvfileBuf,SizeOfFile,0); //recv actuall file
file.write(recvfileBuf,recieved).eof(); //write new file
}while(recieved < SizeOfFile);
ZeroMemory(buffer,20);
}
I know there is a better way of doing what im trying to do but its hard without extensive know how on the subject..Any comments would be greatly apriciated
Thankyou
|
|
|
|
|
use CFtpConnection
never say die
|
|
|
|
|
Question : In MDI application, when I open a new document, I want the frame size set by myself rather than the fixed size set by MFC. I wonder where should I implement this, and how?
Thanks
|
|
|
|
|
In the view, I would have thought. That's the class responsible for the way the document is represented, so when one is constructed and shown, you'd need to size it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Did u try to use this functin for frame ?
SetWindowPos()
find it out in the MSDN for more details
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi,
I have created threads using CreateThread (6 parameters) format in vc++ as following
DWORD ThreadId_1,ThreadId_2;
CreateThread(NULL,0,StartThread1,CREATE_SUSPENDED,0,&ThreadId_1);
CreateThread(NULL,0,StartThread2,CREATE_SUSPENDED,0,&ThreadId_2);
where StartThread1 and StartThread2 are the thread functions correspondingly. 'this' refers to my present main application.
I would like to suspend and resume the threads at any point of time, but I didn't understand how to use SuspendThread and ResumeThread functions. I would really appreciate if someone can help me on this (how to suspend, resume and close threads whereever I need) using the above example.
thanks,
-Pav
-- modified at 17:09 Wednesday 4th January, 2006
|
|
|
|
|
If you call C-run time functions in any of your thread functions, you should be using beginthreadex instead of CreateThread.
If you are using MFC, you should use AfxBeginThread instead of beginthreadex.
Having said that, use the thread handle to ResumeThread to get it started again. You can check return value to decide if it was supposed to actually resume or not. If the return value is zero, the specified thread was not suspended. If the return value is 1, the specified thread was suspended but was restarted. If the return value is greater than 1, the specified thread is still suspended.
Use the handle to the thread to SuspendThread. Be mindful of this warning:
Calling SuspendThread on a thread that owns a synchronization object, such as a mutex or critical section, can lead to a deadlock if the calling thread tries to obtain a synchronization object owned by a suspended thread. To avoid this situation, a thread within an application that is not a debugger should signal the other thread to suspend itself. The target thread must be designed to watch for this signal and respond appropriately.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
Hi Blake,
thanks for ur reply. I am not able to figure out which one is the thread handle, while I am using my thread name ThreadId_1 (assuming its the handle), it is giving syntax error.
Actually in my program I need to make anyone of the threads to be active at any time depending on the user input. So i need to suspend and resume them accordingly. I am not getting the correct syntax on using those functions. Can you gimme some sample syntax code for my example. I am using these threads in my MFC application, but these threads wont handle any windows, but only to do the processing.
I did have another version of my program with AfxBeginThread, but there too I need to know the syntax.
thanks,
-Pav
|
|
|
|
|
HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,
SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId
);
In other words, the value RETURNED from CreateThread is what is used in the calls to Resume and Suspend.
Or, you can get the thread handle using OpenThread, if you know the thread identifier.
HANDLE OpenThread(
DWORD dwDesiredAccess,
BOOL bInheritHandle,
DWORD dwThreadId
);
Be sure to close the handle you opened if oyu use this second approach.
I usually retain the thread handle returnd from CreateThread instead of constantly opening and closing the thread handle.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
Marriage slows down your coding, a baby slows it down even more!
thats something really true ,
actually marriage changes lots of things??
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi!
For some reason, when I'm calling SetBkColor on a device context, the color is just not changing. I've used this function dozens of times in other programs I've written and it's always worked. I have no idea why it isn't working now.
So my code looks like this:
SetBkColor(the_HDC, RGB(100, 255, 255));
TextOut(the_HDC, 100, 100, text, strlen(text));
The text draws fine, but it's always black. The variable 'text' is frequently changed, and always draws correctly, but the color does not change from RGB(0,0,0)
I'm not using double-buffering in this program so the HDC drawn to is the one the user is looking at. What could be wrong?
Thanks!
Kelly Ryan
|
|
|
|
|
SetBkColor sets the background color. Have you seen SetTextColor?
--
I've killed again, haven't I?
|
|
|
|
|
.... I guess I shouldn't be coding on 2 hours sleep with the flu.....
Thanks... I've only used the darned thing like 50 times...
Geesh... I need to go to bed, sorry for wasting your time.
Kelly Ryan
|
|
|
|
|
No problem!
Heck, I spent two days this week looking for some kind of weird regex parser/token extractor combo, then realized "strspn" did all I needed... and I'm healthy, well-rested, and just coming off a week of vacation!
--
I've killed again, haven't I?
|
|
|
|
|
I need C++ code to solve exercises below:
• First, read the text file and show 8 choices for an operator.
• 1) Make a list for first “N” word of frequency repeated.
• 2) Make a list for even “M” word that close to each other.
• 3) Word count.
• 4) Paragraph count.
• 5) Witch paragraph is the largest one – show it by first 3 letter and number of that paragraph.
• 6) Sentence count – each sentences are up to “Dot point”.
• 7) Get a word from operator and after search, show how many used.
• 8) Get a list of words and after search, show how many used by percent.
I am Pouya Vatanpour, from Iran and I study in a college of computer science.
I used Deitel book – programming with C++ 2editin - up to chapter six.
I am waiting for your help and so many thanks if you tell me more ASAP.
Best Regards,
vatanpour@msn.com / vatanpoor@gmail.com
Pouya
|
|
|
|
|
I really hate to tell you this, but you will get more help if you try doing your own homework first. Then ask specific questions.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
The least you could do is to not word it like a homework assignment. Show some initiative, and then ask specific questions. You'll get tons more help that way. See here for more.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
What puzzles me is why people opt for a Computer Science course and then don't want to write code.
|
|
|
|
|
Nishant Sivakumar wrote: What puzzles me is why people opt for a Computer Science course and then don't want to write code.
They think learning computer programming is easy and earns big bucks.
-Prakash
|
|
|
|
|
pvatanpour wrote: Witch paragraph is the largest one
How do you know she's a witch ?
Sorry, I don't usually make fun of people who can't spell, especially people who don't speak English. However, more than anything, you need to do your own homework, and you need to learn to look things up on the web. There are a million sites only a google away with all the info you need to do this stuff.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|