|
You said it is loading but not show on button,the reason is u have to check the button properites as ownerdraw.
It works now
Kiranmaye
|
|
|
|
|
U can directly load on picture control by changing the control properties
Right click on picture control and change type to bitmap and select bitmap id in Image.
|
|
|
|
|
Set the type of button as bitmap and perform the following :
(here m_bit is an object of CBitmap , m_btnStart is the variable for CBitmapButton)
m_bit1.LoadBitmap(IDB_BMPSTART);
HBITMAP hBit1 = (HBITMAP) m_bit1.GetSafeHandle();
m_btnStart.SetBitmap(hBit1);
// Use m_btnStart.SizeToContent() if you want to set the size of the button to that of the image being displayed on it
(open the resource editor and copy the .gif image to the bitmap image in the resource editor)
*******and yes on the picture control you have to set the type as bitmap and pass the image name of the bitmap in the IMAGE option of resource editor
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
-- modified at 5:31 Thursday 2nd March, 2006
|
|
|
|
|
Hello everyone. I would like to know how to launch an application (.exe) when clicking a button on an MFC dialog. Thanks in advance
Aman
|
|
|
|
|
|
Use ShellExecute()
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
Hi,
use ShellExecute()
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
hello members
please help me how to use the runreportwizard method in VC++ 6.0 using crystal reports 11. i have developed a simple mfc which can design, preview, open and save reports. but now i want to add the reportwizard. please help me out.
|
|
|
|
|
Friends ! I need help !
I have to write a programme in Visual C++ 6 which can listen or sniff the serial port, but without opening the port. The sniffer and the programme which communicates through the serial port has to be on the same PC, I have to write a program which can read ( or listen ) the data that goes out and comes in from the serial port, BUT NOT TO OPEN THE PORT, to let communication programmes communicate through serial ports.
If anyone has an idea how to write this sniffer programme, please send me a advise.
Many thanks !
Szilard
SZ
|
|
|
|
|
You cannot do that (or from what I know you cannot do). When I need to do such a thing, I make a 'harware' sniffer . That is, I connect another connector on the wire so I can plug it into another serial port (if you have two on your computer) and I can sniff the data on the port.
Hope this helps
|
|
|
|
|
Thank you for your reply Cedric .
I don't know if you have heard about the HHD Free Serial Port Monitor. That would be a good model for the programme I have to write. I don't know what tehnique they use. This HHD software monitors in a passive mode al the communication done by other software through the serial port, I don't think it opens the port otherwise it could block the communication for other software.
I also have another question, what if I use assembler code, embedded C or something like that, and integrate in my visual C++ code?
I think there has to be a possibility to read the memory location through which the serial communication is done.
Thanks in advance !
Szilard
Szilard
|
|
|
|
|
|
Thank you James your advise was very usefull.
-- modified at 5:22 Thursday 2nd March, 2006
|
|
|
|
|
I recommend looking up "API Hooks." You might be able to set hooks on the API calls used to perform serial communication.
That's where I would start.
|
|
|
|
|
Could somebody please help me out with where to start when coding a multithreaded application in a NON MFC project.
My aim is hopefully quite clear. Lets say I have created a class which upon initialization will do some extensive file parsing, a process which could take a good deal more than 10 seconds. Obviously I don't want my application to freeze and wait for this to complete. I think the best thing to do is inisialize the class under a seperate thread and periodically check as to whether it has finished or not, while at the same time displaying to the user some sort of progress bar.
Problem is I have never before coded any form of Multithreaded app before, and there is very little information to be found about doing such a thing.
|
|
|
|
|
use API CreateThread
nave
|
|
|
|
|
In most cases calling CreateThread is a bad idea - In fact it is probably the first and most common error programmers make when writing a multithreaded program. You should use _beginthread or _beginthreadex - or AfxBeginThread in an MFC application. If you don't call these functions certain structures are not initialized for the thread. For example floating point math may not work and calling CRT functions may not work. The moral of the story is that you shouldn't use CreateThread unless the thread calls only win32 functions, doesn't use floating point and also doesn't call CRT functions.
Steve
|
|
|
|
|
Thanks steve. i didn't know that
nave
|
|
|
|
|
As said by Naveen, you can use CreateThread. But it requires some practise before knowing exactly how to use it in a good way (specifically if you don't want to break your OO design).
But you said that your project is non-MFC, does that means it's a console app or is it a win32 application ? If it's a console app, I don't think you can use CreateThread as it is part of the windows SDK. You'll need to use _beginthread.
Anyway, if you want to keep your OO design, the best way IMO is to make your thread run a function of your class and use a boolean to keep the status of the process (finished or not). You could also post a message to your GUI window to specify that the process is finished (or even that the process has increased of 1%). To make your thread run a member function of your class, you'll have to use a little trick: you cannot supply directly the function to the thread because it doesn't have the same prototype as a global function (implicit this parameter). Thus, you can instead use a static member functino of the class (no this parameter because static functions are shared among all instances of your class) and pass the this pointer in the parameters you can pass in the CreateThread function. Then you get it back in your static function and it lets you call a member function of the class in which you can make your process.
In this way you don't break your OO design.
If its not clear, ask and I can post some code.
|
|
|
|
|
Thanks for your comments. My current project is a Win32 application. One day I may venture into the MFC domain, but not today. I understand the concept of the this pointer in regards to using a thread, I suppose it is pretty much the same as using a timer within a class.
At the moment I am not sure where to start or how to approach this problem. I have a folder containg any number of files which need to read, the time required to do this is quite lengthy. Now I can either stick to my first idea of displaying a splash screen on startup, or I can run this in a seperate thread. If I opt for the first option I would still have problems when it comes to saving data or loading additional user defined files.
I would prefer to keep my OO design as I find it very comfortable. All my data, variables and functions are kept close together, seperated in a way from the main loop.
At the moment I am stuck in a web, I just don't know where to start.
|
|
|
|
|
Where are you stuck exactly ?
Why don't you make a thread that will process the data ? Where is the problem exactly ?
|
|
|
|
|
If you are going to use any of the C-Runtime, use _beginthreadex.
To check if it's done, you can call WaitForSingleObject on the return value of CreateThread or _beginthreadex (which is the thread handle). Or you could just have the parsing thread post a message back to the main window (which you'd probably be doing anyway to update the progress bar.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
for the testing sort() .... what kind of the header can I use for my
program.
yaaqub
|
|
|
|
|
There is an example for sort in MSDN.
The header file used is <algorithm>
Nibu thomas
Software Developer
|
|
|
|
|
Here is an example of how to use std::sort:
-------------------------------------------
#include <iostream>
#include <algorithm>
#include <iterator>
using namespace std;
// Our data.
struct Blah
{
Blah(int Type, const char* pName) :
m_Type(Type), m_pName(pName)
{
}
int m_Type;
const char* m_pName;
};
// Print out a blah.
ostream& operator<<(ostream& s, const Blah& b)
{
s << "Type: " << b.m_Type << ", Name: \"" << b.m_pName << "\"";
return s;
}
// Sort functors.
struct SortByType
{
bool operator()(const Blah& l, const Blah& r) const
{
return l.m_Type < r.m_Type;
}
};
struct SortByName
{
bool operator()(const Blah& l, const Blah& r) const
{
return strcmp(l.m_pName, r.m_pName) < 0;
}
};
struct SortByTypeThenName
{
bool operator()(const Blah& l, const Blah& r) const
{
return SortByType()(l, r) | (!SortByType()(r, l) && SortByName()(l, r));
}
};
// The data.
Blah g_Blahs[] =
{
Blah(1, "George"), Blah(2, "Liam"), Blah(2, "Hank"),
Blah(0, "Abigail"), Blah(1, "Bob"), Blah(0, "Jessica"),
Blah(2, "Con"), Blah(1, "Kyle"), Blah(0, "Faye")
};
int main(int argc, char* argv[])
{
Blah* pBegin = &g_Blahs[0];
Blah* pEnd = &g_Blahs[sizeof(g_Blahs)/sizeof(g_Blahs[0])];
ostream_iterator<Blah> oi(cout, "\n");
// Sort by type.
cout << "Type:\n";
sort(pBegin, pEnd, SortByType());
copy(pBegin, pEnd, oi);
cout << "\n";
// Sort by name.
cout << "Name:\n";
sort(pBegin, pEnd, SortByName());
copy(pBegin, pEnd, oi);
cout << "\n";
// Sort by type and name.
cout << "Type and name:\n";
sort(pBegin, pEnd, SortByTypeThenName());
copy(pBegin, pEnd, oi);
cout << "\n";
return 0;
}
Steve
|
|
|
|