|
If you got the code then please send ma at my Gmail naeemyaseen78@gmail.com
|
|
|
|
|
Dear All,
I create a modeless dialog in my MFC and in the dialog I read a big file (15 MB) on a button click even. Until the code the finished reading the dialog hangs up. This means when I switch to other application then my modeless dialog is not viewable.
I dont want to use threads to read the file to run in a separate process. Is it possible to make the dialog accessible when it reads a big file. Please advice me.
Many thanks in advance.
|
|
|
|
|
|
|
Hi,
the correct way to do this is by adding one thread; there is no separate process involved.
your main thread should be available for GUI operations, hence not be involved in lengthy operations.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Dear Jijo, Michael Schubert and Luc Pattyn ,
Thank you so much for your kind replies. I followed the approach suggested by Michael Schubert ( I mean pumping message). Actually I dont want to use the Threads.
Can you please tell whether pumping messages is unsafe and Thread is safe ?
Many thanks in advance.
|
|
|
|
|
bhanu_8509 wrote: Can you please tell whether pumping messages is unsafe
Not to my knowledge. In fact, you can mess up things easily (if not written properly) by using threads because of synchronisation issues.
However, the "PumpMessage" method is still a "hack" whereas using threads should be the preferred approach.
|
|
|
|
|
Hello there!
I am trying to solve a problem for a project i took and i am in the final
part of it...(view below for my until now code)
Well the aim is to calculate the entropy of a file and then to use
Hamming to code it. I managed to make both parts based on what I learned
from the class and read in the book. (Please if you are familiar with the
object tell me if it is correct )
So, my problem is that I am not able to merge those two parts below (you
dont need to read the theory for it).. like finding the entropy and then
continue for the coding of that file.
Any help, advice, anything is appreciate.
Thank you!
Entropy Calculation
#include "BufferedNode.h"<br />
#include "Buffer.h"<br />
#include "Vector.h"<br />
#include <strstream><br />
#include <math.h><br />
<br />
#ifdef HAVE_VALUES_H<br />
#include <values.h><br />
#endif<br />
<br />
#ifdef HAVE_FLOAT_H<br />
#include <float.h><br />
#endif<br />
<br />
class Entropy;<br />
<br />
DECLARE_NODE(Entropy)<br />
<br />
<br />
<br />
class Entropy : public BufferedNode {<br />
<br />
int inputID;<br />
int outputID;<br />
<br />
public:<br />
Entropy(string nodeName, ParameterSet params)<br />
: BufferedNode(nodeName, params)<br />
<br />
{<br />
inputID = addInput("INPUT");<br />
outputID = addOutput("OUTPUT");<br />
}<br />
<br />
void calculate(int output_id, int count, Buffer &out)<br />
{<br />
ObjectRef inputValue = getInput(inputID, count);<br />
<br />
const Vector<float> &in = object_cast<Vector<float> > (inputValue);<br />
int inputLength = in.size();<br />
<br />
Vector<float> &output = *Vector<float>::alloc(1);<br />
out[count] = &output;<br />
<br />
float s2=0;<br />
float entr=0;<br />
for (int i=0;i<inputLength;i++)<br />
{<br />
s2+=in[i]*in[i];<br />
}<br />
s2 = 1/s2;<br />
<br />
for (int i=0;i<inputLength;i++)<br />
{<br />
if (in[i] != 0)<br />
entr -= s2*in[i]*in[i] * log(s2*in[i]*in[i]);<br />
}<br />
output[0] = entr;<br />
}<br />
<br />
};<br />
Hamming Coding
<br />
<code>#include<iostream.h> <br />
#include<math.h> <br />
void hanming() <br />
{ <br />
int i,n,k=2; <br />
int h[20]; <br />
for(i=0;i<20;i++)h[i]=0; <br />
cout<<"bla bla"<<endl; cin="">>n; <br />
while(pow(2,k)<n+k+1)k++; cout=""><<"bla bla"<<endl; for(i="1;i<=n+k;i++){" if(i!="1&&i!=2&&i!=4&&i!=8)cin">>h[i]; <br />
} <br />
h[1]=(h[3]+h[5]+h[7]+h[9]+h[11]+h[13]+h[15])%2; <br />
h[2]=(h[3]+h[6]+h[7]+h[10]+h[11]+h[14]+h[15])%2; <br />
h[4]=(h[5]+h[6]+h[7]+h[12]+h[13]+h[14]+h[15])%2; <br />
h[8]=(h[9]+h[10]+h[11]+h[12]+h[13]+h[14]+h[15])%2; <br />
for(i=1;i<=n+k;i++)cout<<h[i]; jiaoyan(int="" a[],int="" n)="" {="" i,p1,p2,p4,p8,m;="" int="" h[20];="" for(i="0;i<n;i++)h<br />
<br />
[i+1]=a[i];" k="2;" p1="(h[1]+h[3])%2;" p2="(h[2]+h[3])%2;" m="2*p2+p1;" return="" m;="" }="" if(n="=3){">=5&&n<=7){ <br />
p1=(h[1]+h[3]+h[5]+h[7])%2; <br />
p2=(h[2]+h[3]+h[6]+h[7])%2; <br />
p4=(h[4]+h[5]+h[6]+h[7])%2; <br />
m=4*p4+2*p2+p1; <br />
return m; <br />
} <br />
if(n>=9&&n<=15){ <br />
p1=(h[1]+h[3]+h[5]+h[7]+h[9]+h[11]+h[13]+h[15])%2; <br />
p2=(h[2]+h[3]+h[6]+h[7]+h[10]+h[11]+h[14]+h[15])%2; <br />
p4=(h[4]+h[5]+h[6]+h[7]+h[12]+h[13]+h[14]+h[15])%2; <br />
p8=(h[8]+h[9]+h[10]+h[11]+h[12]+h[13]+h[14]+h[15])%2; <br />
m=8*p8+4*p4+2*p2+p1; <br />
return m; <br />
} <br />
else{ <br />
cout<<"bla bla"<<endl; return="" -1;="" }="" ����="" void="" main()="" {="" hanming();="" coco;="" int="" i,n,m,h[20];="" <br />
<br />
cout=""><<endl; cout=""><<"bla bla"<<endl; cin="">>n; <br />
cout<<"bla bla"<<endl; for(i="0;i<n;i++)cin">>h[i]; <br />
m=jiaoyan(h,n); <br />
if(m==0)cout<<"bla bla"<<endl; if(m!="0)cout<<"bla bla"<<m;" cout=""><<endl; cin="">>coco; <br />
}
|
|
|
|
|
kordellas wrote: So, my problem is that I am not able to merge those two parts below
I see a class named Entropy and a function named hanming() . What are you wanting to do with them?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
When you want to add hamming() method to class Entroy, then add like below.
class Entropy {
public:
void hammming() {
};
};
If you did not want above, I am not sure what you want to do, sorry.
|
|
|
|
|
hi.
I use CImage to display *.png and *.gif, but the image don't transparent.
my code:
CImage img;
img.Load(_T("D:\\1.png"));
BOOL bIsTrans = img.IsTransparencySupported();
img.Draw(pDC->GetSafeHdc(), 20, 20);
help!
One world, one program!
|
|
|
|
|
|
I am working on Linux environment. I want convert a PGM file into PBM file.
Could you please guide me about the logic required to implement a Portable Bitmap file.
I mean how to deal in writing a hexadecimal values 0x80.
How to create a new byte.
Thank you very much in advance .
|
|
|
|
|
singh.vikas8508 wrote: I mean how to deal in writing a hexadecimal values 0x80.
What?
singh.vikas8508 wrote: How to create a new byte.
What do you mean, exactly?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thank you very much for your reply...
I need logic to implement PBM file. I have raw data of PGM file. Now I want to convert it into Pixels of PBM.
Thats why I used 0x80.
Please send me if you have any other logic or idea.
|
|
|
|
|
Why don you use the libnetpbm library http://netpbm.sourceforge.net/doc/libnetpbm.html[^]? It looks promising.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
No. we are not suppose to use built-in- libraries. We have to implement it in C language.
|
|
|
|
|
singh.vikas8508 wrote: No. we are not suppose to use built-in- libraries. We have to implement it in C language.
Is this a homework ? Because I don't see any valid reason not to use an existing library. That would be really stupid to reimplement everything yourself...
(and if you followed the link Carlo gave you, you could see that the library is written in C).
|
|
|
|
|
This is not a homework.this is a predefine formate which we have to follow. I have finished most part of this question like getting data from the PGM file , now i am looking to implement the PBM file .
|
|
|
|
|
Ok, but what forbids you to use external C libraries ? This will be much more efficient than redoing everything yourself.
On the other hand, if you really want to code everything yourself, you can simply look for the PBM file format[^]
|
|
|
|
|
|
It looks like a very simple file format. What is your trouble with?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
if i have understood your problem correctly then it is only with writing bits and hexa values to a file.
if iam right, then please specify your task clearly. we shall attempt it.
did you mean to convert the 0x80 to bits or vice versa?
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|