|
I know.. it's maybe a simple question. How can I use the printer?
I've made a database-application and now I'd like to print some tables but somehow it won't work
It's an MFC-SDI application.
I know that I must edit a DC but I don't know which function I have to use. The app-wizard already made a print-preview. But there must be some functions to override that I can edit the DC and "draw" with my data.
btw. sorry for my bad english
thanks for help.
|
|
|
|
|
Hii All
I have a realy big question
while running my application it crashes on HEeapValidate function
can anyone help me please with this issue ?
10'x
|
|
|
|
|
You've either overrun or underrun a buffer, which has trashed a heap data structure which it uses to keep track of what blocks are allocated and where they are.
I suggest using the PageHeap tool from Microsoft's Application Compatibility Toolkit[^] to turn on the 'full-page heap'. This causes each heap allocation to happen at the end of a memory page, with the next page being reserved as a guard page. As soon as the overrun occurs, your program will get an access violation.
If the problem is an underrun, there's another option for putting the allocation at the beginning of a fresh page and keeping the page before as a guard page.
If the problem is in a C runtime-allocated block (i.e. allocated with malloc() or new ) this won't necessarily show the problem immediately, as the CRT does its own memory allocation. Use the CRTDBG.H facilities to find your problem.
|
|
|
|
|
maybe I will elabrate some more.
the problem is caused from a multithreaded server.
when I use new() or malloc().
as I know allocation of memory should not trash the heap
so how can I know where to start fixing this problem
|
|
|
|
|
We ran into some similar problems -- with a busy multithreaded server... We 'think' that the MS default memory manager doesn't work too well in that environment, and eventually leads to some corruption.
We switched to a commmercial memory manager -- "SmartHeap" -- it's not cheap, but it's quick and comprehensive. Includes built-in debug, catches double deletes, and other stuff.
Check them out at: www.microquill.com
It was worth $$$ in saved time and energy, and servers that don't crash anymore. At least they don't crash for memory allocation errors. I wish MicroQuill would pay me for each time I endorse their product, we are really really pleased with it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Your heap is already trashed at the point that you allocate. The heap manager code is trying to find a block that it can give you, but the corrupted block headers prevent it from doing so.
There's some other overrun that's causing this problem.
|
|
|
|
|
I am trying to spin through an array in a struct and for each element in that array I want to get the value of another array in another struct.
The problem I am having is that the value is always the same.
My structs are:
<br />
struct TSimHeader<br />
{<br />
char Name[45][20];<br />
char Unit[45][20];<br />
double Min[45];<br />
double Max[45];<br />
int SignalCount;<br />
int SimStatus;<br />
<br />
}static TSimHeader_arr[10];<br />
<br />
<br />
struct TSimSignal<br />
{<br />
double Value[45];<br />
double TimeStamp;<br />
<br />
}static TSimSignal_arr[10];
My function to match elements in the TSimHeader_arr[0].Name[] array with the same element in the TSimSignal_arr[0].Value[] is:
void Tflight_data::getValues(){<br />
int numSignals = RFMAccess::TSimHeader_arr[0].SignalCount;<br />
<br />
for(int i=0; i<numSignals; i++){<br />
char* temp = RFMAccess::TSimHeader_arr[0].Name[i];<br />
char* temp2 = RFMAccess::TSimHeader_arr[0].Name[i+1];<br />
<br />
if(strcmp(temp, "pla"))<br />
display_pla_level(RFMAccess::TSimSignal_arr[0].Value[i]);<br />
<br />
if(strcmp(temp, "pitch_stickF")&& strcmp(temp2, "roll_stickF")){<br />
roll = (RFMAccess::TSimSignal_arr[0].Value[i] / 10.0);<br />
pitch = (RFMAccess::TSimSignal_arr[0].Value[i+1] / 10.0);<br />
flight_data->fwd_pl->Repaint();<br />
}<br />
if(strcmp(temp, "nose_wow")){<br />
if(RFMAccess::TSimSignal_arr[0].Value[i] != 0)<br />
front_wheel_led->Active = true;<br />
}<br />
if(strcmp(temp, "left_wow")){<br />
if(RFMAccess::TSimSignal_arr[0].Value[i] != 0)<br />
left_wheel_led->Active = true;<br />
}<br />
if(strcmp(temp, "right_wow")){<br />
if(RFMAccess::TSimSignal_arr[0].Value[i] != 0)<br />
right_wheel_led->Active = true;<br />
} <br />
if(strcmp(temp, "pitch_trim"))<br />
pitch_data_lb->Caption = (AnsiString)RFMAccess::TSimSignal_arr[0].Value[i];<br />
<br />
if(strcmp(temp, "roll_trim"))<br />
roll_data_lb->Caption = (AnsiString)RFMAccess::TSimSignal_arr[0].Value[i];<br />
<br />
if(strcmp(temp, "yaw_trim"))<br />
yaw_data_lb->Caption = (AnsiString)RFMAccess::TSimSignal_arr[0].Value[i];<br />
<br />
}<br />
}
The values should be different depending on the word in the char array. It should match with the exact element in the Values array.
Any ideas why I am getting the same value on each if statement?
I hope I explained it well enough.
Thanks,
steven
|
|
|
|
|
Probably because you are always looking at the same offset into the RFMAccess::TSimHeader_arr and RFMAccess::TSimSignal_arr structures - zero!
|
|
|
|
|
see every occurrance of "TSimSignal_arr[0]."
I'd also consider cleaning up your data structures. I've been doing this for 10+ years, and I still can't stand doubly indexed (2d) arrays used for characters.... not intuitive at all.
<br />
struct TSimHeader<br />
{<br />
char Name[45][20];<br />
char Unit[45][20];<br />
double Min[45];<br />
double Max[45];<br />
int SignalCount;<br />
int SimStatus;<br />
}static TSimHeader_arr[10];<br />
<br />
<br />
struct TSimSignal<br />
{<br />
double Value[45];<br />
double TimeStamp;<br />
}static TSimSignal_arr[10];<br />
couldn't this be something more like:
<br />
#define MAX_ENTRIES (45)<br />
#define MAX_ARRAY_SIZE (10)<br />
#define MAX_STRING_SIZE (20)<br />
<br />
struct TSimHeaderEntry<br />
{<br />
char Name[MAX_STRING_SIZE];<br />
char Unit[MAX_STRING_SIZE];<br />
double Min;<br />
double Max;<br />
};<br />
<br />
<br />
struct TSimHeader<br />
{<br />
TSimHeaderEntry Entries[MAX_ENTRIES];<br />
int SignalCount;<br />
int SimStatus;<br />
}static TSimHeader_arr[MAX_ARRAY_SIZE];<br />
<br />
<br />
struct TSimSignal<br />
{<br />
double Value[MAX_ENTRIES];<br />
double TimeStamp;<br />
<br />
}static TSimSignal_arr[MAX_ARRAY_SIZE];<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
strcmp() returns 0 if the strings are the same, non-zero if they are different. Your if statements will always be executed if the strings are not the same, which I assume is the majority of times. It looks like you want the if statements to be executed if the strings are equal, so you'll need to modify them like this:
if(strcmp(temp, "pla") == 0) etc...
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I would like to query my monitor for its EDID data. From another thread here I got an advice to communicate directly with my video card (since there's no Windows API call for querying the EDID, only in the DDK), but I don't know how to use the nvidia driver's functions in my code.
I thought there was a lib or a dll which I had to link into my code and a .h file which contains the name of the functions included in the lib or dll. I've downloaded the nvsdk which contains everything from openGL to directX but there's nothing there I could use.
I've also checked NVidia's developer site, but I haven't found any valuable info regarding my problem.
Any ideas?
|
|
|
|
|
well.. in a program i have got a lot of functions like these (it is function based, so no chance in using a class [would be my first idea to solce this problem])
fun2;
fun3;
void fun1(int i)
{
if(i == 0)
fun2();
else
fun3();
}
well.. now there are a lot of fun2's and fun3's so there are a lot of fun1's too..
is there any neat solution doing this with templates ?
thanks for your help,
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Not with templates that I can think of, but you can use the preprocessor...
#define CHOOSE_FUNCTION(i, f1, f2) do { if((i) == 0) (f1)(); else (f2)(); } while(0)
CHOOSE_FUNCTION(i, fun2, fun3);
CHOOSE_FUNCTION(j, fun4, fun5);
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Bernhard wrote:
is there any neat solution doing this with templates ?
What you might have been thinking of was template specialisation based on an integer constant - it's a possiblity, but it's unlikely that it would work. Most of the time you want to dispatch the function based on a number specified at compile time run time.
Bernhard wrote:
it is function based, so no chance in using a class
Ryan's solution might be the best in this case, but consider the alternative of using a standard map to dispatch the functions
#pragma warning(disable:4786)
#include <iostream>
#include <map>
#include <functional>
using namespace std;
typedef void (*func)();
void fun1()
{
cout << "a" << endl;
}
void fun2()
{
cout << "b" << endl;
}
int main()
{
std::map<int,func> m;
m[1] = &fun1;
m[2] = &fun2;
m[1]();
m[2]();
return 0;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
well, this could really be a solution..
but the problem is somewhere different:
i have got 2 sets of functions, doing the same thing..
it depends on 1 parameter which function i have to chose (from set a or set b)
!! WARNING PSEUDOCODE !!
!! this is not intended to run, just to show the concept !!
void a_get();
void b_get();
void a_set();
void b_set();
void get()
{
if (a)
a_get();
else
b_get();
}
void set()
{
if (a)
a_set();
else
b_set();
}
now it is very cumbersome to write this for every function and i wanted to know if there isn't any possibility to write something like:
template <fun1, fun2>
{
if (a)
fun1;
if (b)
fun2;
}
template<&a_get, &b_get> get;
template<&a_set, &b_set> set;
yeah.. and this was what it was all about.
thanks for your efforts (both of you, altough i write you back)
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
well.. after writing the pseudocode (thinking again about this problem), i found out this solution by myself..
template <void f1(), void f2>
class call_fun
{
call_fun () {};
public:
call_fun (char c)
{
if('A' == c)
{
cout << "call_fun: A selected" << endl;
f1();
}
else
{
cout << "call_fun: not A selected" << endl;
f2();
}
};
};
void fun11()
{
cout << "Hello from fun11" << endl;
}
void fun12()
{
cout << "Hello from fun12" << endl;
}
void fun21()
{
cout << "Hello from fun21" << endl;
}
void fun22()
{
cout << "Hello from fun22" << endl;
}
int main()
{
call_fun<&fun11, &fun12> a ('A');
call_fun<&fun11, &fun12> b ('B');
cout << endl;
call_fun<&fun21, &fun22> c('A');
call_fun<&fun21, &fun22> d('B');
return 0;
}
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
I have two questions.
1. Is there any way to check to see if there is a device on the other end of the serial port. The device itself does not have anything that will send out "yes i am here".
2. The device i am connecting to constantly send data unless a stop command is issued, how do i keep receiving the incoming data? Right now I execute the following code using a receive button, but I have to keep pressign the receive button to keep getting the code:
// Receive on the Serial Port
if( m_MySerialPort.IsOpen() )
{
m_bytesRead = m_MySerialPort.Read( m_readBuffer, 100 );
m_ctrlTextIn.SetWindowText(m_readBuffer);
}
else AfxMessageBox(" Compass not responding in Recieve function!");
|
|
|
|
|
1) If the device is constantly sending data unless a stop command is issued then you already know if it is attached (or that something is attached). Just send a start command, if you receive any data it is attached.
2) You could start a timer (StartTimer(), KillTimer()) or use a seperate thread to poll the serial port.
INTP
|
|
|
|
|
Hey,
I've got one question. I need to display an AutoCAD or Microstation drawings within a SDI frame. But I don't know how to do this. Is it possible with DirectX or OpenGL??
It would be nice to bet some helpfull informations.
Thanks for any replies!!!
|
|
|
|
|
Check www.opendwg.org[^]. There's a toolkit and a viewkit which put together should help. It's members-only downloads, but thats the most I can think of at the moment. There are a couple of articles here, but they are for writing DXF, not reading it.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I would like to edit a Russian (Cyryllic) string in MFC's Edit/RichEdit box, then DDX it and write it to file... of course to be read again and put into the edit box.
Should I use Unicode (i.e. compile my application for Unicode)? Will it work with Win9x? How do I setup Edit box for cyryllic font?
Regards,
BB
|
|
|
|
|
My inclination would be to use Unicode, but I haven't worked with a non-english version of Windows, so I don't know if it's absolutely necessary. If you want it to work on an english version of Windows, then yes, you'll have to use Unicode. In this case, it won't work with Win9x, unless you link with the Microsoft Layer for Unicode (check the MSDN docs for this). You should be able to use any font that supports cyrillic characters. I think the Arial Unicode font does - you'll have to check, and distribute one with your app if necessary.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Is there a way to get the number of logical processors in a Windows XP system? If I see that the application is running on Windows XP and that hyperthreading is enabled (how do I do that?) I guess I could just divide by two?
Are there any api calls for this? I found something about GetLogicalProcessorInformation , but that didn't seem to be what I need.
Thanks,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
What is the difference between normal CPU and logical CPU? One solution is GetSystemInfo().
Kuphryn
|
|
|
|
|
With Hyperthreading you have physical processors and logical processors. Example, let's say:
I have to physical processors each one is also a logical processor. I then enable hyperthreading on both CPUs. Windows now thinks that I have 4 logical processors, that being each physical processor now represents two logical.
I wish to be able to get the number of physical processors and then also the number of logical processors. The reason for this is that if I were to have 4 real physical processors I might then spin out 8 threads. On the other hand, if I have only two physical processors that each are hyperthreaded I would only spin out 6 threads (logical processors aren't as capable as a physical processor).
Hope this offers some explanation.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|