|
Thanks
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hi All
Removable hard disks ( USB hard disk ) are being displayed even when selected drive type is Local Disk. This problem doesn't occur with removable flash drives.
How can i show Removable hard disks ( USB hard disk )is a Logical Drive?Plz help me
|
|
|
|
|
Hello All,
I am doing an SDI application in MFC(.Net 2008 platform). In my project, when i click on any button, i have to create a child window in the mainframe window. This child window having no caption, title bar, system menu. i want only border for that window. This child window will always be displayed on the Mainframe window, even i click anywhere on the mainframe window.
I have created window using Create() function and Set its position using SetWindowsPos() function. as follwing;
**************************
CFrameWnd* pFrame ;
pFrame = new CFrameWnd;
pFrame->Create(NULL,NULL, WS_OVERLAPPEDWINDOW ,rect,NULL,NULL,0,poContext);
pFrame->ModifyStyle(WS_CAPTION + WS_OVERLAPPEDWINDOW + WS_TILEDWINDOW, WS_BORDER,SWP_+ SWP_NOMOVE +SWP_NOZORDER );
pFrame->InitialUpdateFrame(pDocument,TRUE);
pFrame->SetWindowPos(&CWnd::wndTopMost,x,y,x1,y1,SWP_SHOWWINDOW);
pFrame->ActivateFrame(SW_SHOWNORMAL);
**************
Now the problem is that, when i minimize the Mainframe window, child window always be there on the screen. i want to minimize this child window also along with Mainframe window. How can i do this. Please give me any hint with the help of code.
Which flag i have to set while creating the window or in the SetWindowPos() function.?
Also when i create child window, its name is displayed on the taskbar, when it is created. I dont want to show this entery on the taskbar.
Thnaks in advance.
|
|
|
|
|
i have a dialog box and in dialog box there r 4 check boxes.whenever check box is checked it becomes 1 and for unchecked, value becomes 0.so user may check or uncheck the check boxes according to that i need to get the values of check boxes and i need to convert it into decimal.
eg 1)if 1st and 2nd checkboxes are clicked then it will be as 1100
2)if 1st and 4th check boxes are checked then it becomes as 1001 and
3)if 2nd check box is checked then it becomes as 0100
i want to convert this value to decimal, how can i do this?
thanks in advance.
|
|
|
|
|
You just need to obtain the state of the check box and use some simple bitwise operations. You'll want to do something like this:
int myNumber = 0;
if (checkBox4.isChecked()) myNumber &= 1;
if (checkBox3.isChecked()) myNumber &= 2;
if (checkBox2.isChecked()) myNumber &= 4;
if (checkBox1.isChecked()) myNumber &= 8;
How you determine the checkbox's state is up to you.
|
|
|
|
|
enhzflep wrote: You just need to obtain the state of the check box and use some simple bitwise operations. You'll want to do something like this:
int myNumber = 0;
if (checkBox4.isChecked()) myNumber &= 1;
if (checkBox3.isChecked()) myNumber &= 2;
if (checkBox2.isChecked()) myNumber &= 4;
if (checkBox1.isChecked()) myNumber &= 8;
Two notes:
- AFAIK there's no
isChecked method available (even CMFCButton has IsChecked , i.e. starting uppercase). - The correct bitwise operator is OR (
| ), instead of AND (& ).
Be careful when proposing code.
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]
|
|
|
|
|
hi there,
i'm trying to set up a hash map such as:
class ObserversByMessageMap :
public stdext::hash_map<messagekey,>
{};
and i've got MessageKey defined with these operators:
bool operator==(const MessageKey& other)const;
bool operator!=(const MessageKey& other)const;
bool operator<(const MessageKey& other)const;
bool operator>(const MessageKey& other)const;
operator size_t(void)const;
something doesn't work quite right however. i'm trying to do something like:
MessageObserverSet& observers = (*m_observersByMessageMap)[key];
observers.insert(observer);
but it appears that the map (either hash or map) seems to collide with a *different* key than what i expect, and therefore adds the observer to the wrong pre-existing key.
i figured the operator==() is supposed to prevent that from happening, but it aint being called. instead the size_t hash is called and also the < operator, which i've defined as:
bool
MessageKey::operator<(const MessageKey& other)const
{
bool lessThan = false;
if(m_messageId <= other.m_messageId)
{
if(m_objectId < other.m_objectId)
{
lessThan = true;
}
}
return lessThan;
}
since m_objectId is a nested object.
any ideas? in mfc this kind of stuff worked no problem...
|
|
|
|
|
My directory structure is like the following
Solution Directory
--Project1
--Project2 From Project2 , I have to use classes written in Project1 . I have included the header files like the below in Project2
#include "../Project1/SomeHeader.h" I can see the classes in intellisense but the problem occured with linker. It is saying about unresolved external symbols.
I am looking for a method to link the file to Project1 . Any thoughts?
EDIT:
I solved it by adding the project dependencies. Right click on the project -> Project dependencies -> Check the Project1 , save and build.
I'd like to hear from you guys that is this the right approach to solve the above described problem?
Thanks
modified on Monday, December 29, 2008 11:25 PM
|
|
|
|
|
What kind of projects are Project1 and Project2 ? Is Project1 a library ? If yes, then your approach is the correct one (of course you need to add the library in the project settings of Project2).
|
|
|
|
|
Cedric Moonen wrote: Is Project1 a library
Yes. Project1 is a library.
Cedric Moonen wrote: of course you need to add the library in the project settings of Project2
Did you mean the linker settings? If yes, I haven't done that but the build and linking was successful. Am I missing something?
|
|
|
|
|
Christian Flutcher wrote: If yes, I haven't done that but the build and linking was successful
That's a bit strange... Normally you should have added it in the project properties: "Linker" category" -> "Input" and you should add it in the "Additional Dependencies".
EDIT: or another way to do it is to make use of a #pragma. That's what you did maybe ? In such case, you don't need to change the properties of project 2.
|
|
|
|
|
Hi!
I have been trying for hours now to get a code snippet to work. It's just a simple little code that is supposed to write an audio stream in a newly created avi file. I've worked out writing bitmaps but this just won't work! I get no errors from AVIStreamSetFormat and no error from AVIStreamWrite() but when I listen to the resulting avi file I just hear random noise (this plus the fact that my code crashes when I try to write bigger chunks of data leads me to believe that AVIStreamWrite tried to write from memory I did not tell it to).
Here's my code:
#include <windows.h><br />
#include <iostream><br />
#include <vfw.h><br />
#pragma comment (lib,"Vfw32.lib")<br />
using namespace std;<br />
<br />
#define INPUT_WAVE L"C:\\cosmic.wav"<br />
#define OUTPUT_AVI L"C:\\testarN.avi"<br />
<br />
struct WAVE_HEADER<br />
{<br />
char ChunkID[4];<br />
int ChunkSize;<br />
char Format[4];<br />
char SubChunk1ID[4];<br />
int SubChunk1Size;<br />
short AudioFormat;<br />
short NumChannels;<br />
int SampleRate;<br />
int ByteRate;<br />
short BlockAlign;<br />
short BitsPerSample;<br />
int Subchunk2ID;<br />
int Subchunk2Size;<br />
};<br />
<br />
<br />
int main ()<br />
{<br />
DeleteFile(OUTPUT_AVI);<br />
DWORD meh;<br />
<br />
HANDLE fhandle;<br />
fhandle=CreateFile(INPUT_WAVE,GENERIC_READ,0,NULL,3,0,NULL);<br />
<br />
<br />
WAVE_HEADER wh;<br />
cout << sizeof(wh) << endl;<br />
ReadFile(fhandle,&wh,sizeof(wh),&meh,NULL);<br />
<br />
cout << wh.Subchunk2Size << endl;<br />
<br />
<br />
BYTE *audiodata = new BYTE[wh.Subchunk2Size];<br />
ReadFile(fhandle,audiodata,wh.Subchunk2Size,&meh,NULL);<br />
cout << meh << endl;<br />
<br />
<br />
<br />
<br />
PAVIFILE avifile;<br />
PAVISTREAM avistream;<br />
<br />
AVIFileInit();<br />
<br />
AVIFileOpen(&avifile,OUTPUT_AVI,OF_CREATE,NULL);<br />
<br />
WAVEFORMATEX wfx;<br />
memset(&wfx,0,sizeof(wfx));<br />
wfx.wFormatTag=wh.AudioFormat;<br />
wfx.nBlockAlign=wh.BlockAlign;<br />
wfx.nAvgBytesPerSec=wh.ByteRate;<br />
wfx.nChannels=wh.NumChannels;<br />
wfx.wBitsPerSample=wh.BitsPerSample;<br />
wfx.nSamplesPerSec=wh.SampleRate;<br />
<br />
AVISTREAMINFO asi;<br />
memset(&asi,0,sizeof(asi));<br />
asi.fccType=streamtypeAUDIO;<br />
asi.dwScale=wfx.nBlockAlign;<br />
asi.dwRate=wfx.nSamplesPerSec*wfx.nBlockAlign; <br />
asi.dwQuality=-1;<br />
<br />
<br />
AVIFileCreateStream(avifile,&avistream,&asi);<br />
cout << avistream << endl;<br />
<br />
<br />
cout << AVIStreamSetFormat(avistream,0,&wfx,sizeof(wfx)) << endl;<br />
<br />
cout << wh.Subchunk2Size/(wh.BitsPerSample/8)/wh.NumChannels << endl;<br />
cout << AVIStreamWrite(avistream,0,100*1000,<br />
&audiodata,100*1000*2,0,0,0) << endl;<br />
<br />
<br />
<br />
AVIStreamRelease(avistream);<br />
AVIFileRelease(avifile);<br />
AVIFileExit();<br />
<br />
delete [wh.Subchunk2Size]audiodata;<br />
<br />
CloseHandle(fhandle);<br />
<br />
return 0;<br />
}<br />
<br />
<br />
<br />
</vfw.h></iostream></windows.h>
I've used resources from the following places:
http://msdn.microsoft.com/en-us/library/ms712636(VS.85).aspx[^]
http://ccrma.stanford.edu/courses/422/projects/WaveFormat/[^]
http://www.adp-gmbh.ch/win/programming/avi/avi.html[^]
Hopefully someone can take the time to look over my code and give me some suggestions.
Thanks in advance!
|
|
|
|
|
Could someone help me / point me to where I can find a source code of this API?
No such thing in Google searches.
Thanks for reading
Vaclav
|
|
|
|
|
|
Also sorry, but I am not looking for applications of this API.
Unless I have missed it, in your search, all of these are just that - applications of capCreateCaptureWindow.
capCreateCaptureWindow "creates" preview of the AVI frame and I am assuming that it does it using bitmap. I like to see the actual source code for it.
Anyway, thanks for your help.
Vaclav
|
|
|
|
|
I get the following error upon program close - NOT while program is running, but when it shuts down:
'Notify.exe': Loaded 'C:\Windows\System32\rsaenh.dll'
First-chance exception at 0x01001df6 in Notify.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
Unhandled exception at 0x01001df6 in Notify.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
How do I find the error. Doesn't happen in Debug compilation l only in Release mode.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: I get the following error upon program close - NOT while program is running, but when it shuts down
Welcome in the CP's memorable quotes [^].
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]
|
|
|
|
|
More information is needed. How do you know it involves a CString if the application is third party? The rsaenh.dll is a Microsoft DLL which provides cryptographic functionality. The 0xfeeefeee value is heap memory that has been deleted.
Btw, you can attach the visual studio debugger to release builds.
How to: Debug a Release Build[^]
Best Wishes,
-David Delaune
|
|
|
|
|
I say CStringT because that is what is shown when I ask for debug info ie,
" ~CStringT
{
}
"
I'm already setup for release build debugging. But as I said I don't use CStringT I use only CString.
A C++ programming language novice, but striving to learn
|
|
|
|
|
In the main method of some code I'm re-factoring to Java there is this call in the main method, which i presume is seeding all the random numbers.
srand(0);
In my java interpretation of this code I have used the following call
app.randomiser.setSeed(0); //(randomiser = new Random());
The main problem is that as I posted earlier, I'm trying to do in-line what the following #define call in the C++ code does;
#define rand01 (0.9999999*double(rand())/RAND_MAX)
I know this produces random numbers between 0 and 1, which is then applied to a integer variable Ne (800) to produce a random value from 0 to 800 which is then floored to produce the integer value.
neurSwitch = randomiser.nextDouble(); // This is how I produce the random in Java
r = (int)(Math.floor(Ne*generateRandom())); //Random applied to the variable Ne in Java, getRandom returns the value of neurSwitch
The C++ code does this all in one line thanks to the #define statement
val = floor(N*rand01);
The two different implementations are producing massively different results, which is kinda an issue, as I'm trying to exactly reproduce the functionality from the C++ code.
My 2 questions are:
Does the seeding function work differently in Java and C++?
Is the Java reproduction of the #define rand01, doing the correct thing?
Many thanks
Give me strength, give me caffeine
|
|
|
|
|
Hi,
why would the built-in random function in Java behave the same as the built-in random function in
the one C++ implementation you have been using so far? There is an infinite number of random generators after all, so even starting from the same seed value, the sequence is unlikely to be the same. Have you ever compared random generators from different C++ systems?
If you need this to be identical, you have but two choices:
- call the original implementation, use Java Native Interface (JNI) to get it;
- copy the C++ implementation using your own Java code.
What I have done in the past is turn the random stuff into my own class, and in there choose between the built-in random generator (which is fast and good), and my own (which is portable, slower and
maybe good, and helps in comparing app results).
|
|
|
|
|
c#_keithy wrote: Does the seeding function work differently in Java and C++?
Are two random generators supposed to produce the same sequence?
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]
|
|
|
|
|
Pallini,
Given a seed, two different random number generation algorithms will return different random values. Worse yet, all random number generators have the property have after a certain number of random numbers being generated, they repeat themselves. The length of this sequence is called the period.
Over the years, there has been a fair amount of theory on how to develop a good random number generator. I believe the one that comes with the Microsoft C++ compiler is a good one and it has a very long period. I do not know about the one that comes with the Java compiler except that it almost certainly uses a slightly different algorithm and therefore it will have a different period. If you need the same results on both C++ and Java, I strongly recommend that you implement your own random number generator.
Bob
|
|
|
|
|
BobInNJ wrote: Given a seed, two different random number generation algorithms will return different random values.
I know, that's fine.
BobInNJ wrote: Worse yet, all random number generators have the property have after a certain number of random numbers being generated, they repeat themselves.
I know, there's a reason they're called pseudo-random generators.
BobInNJ wrote: The length of this sequence is called the period.
Of course: repetaing patterns have a period.
BobInNJ wrote: Over the years, there has been a fair amount of theory on how to develop a good random number generator. I believe the one that comes with the Microsoft C++ compiler is a good one and it has a very long period. I do not know about the one that comes with the Java compiler except that it almost certainly uses a slightly different algorithm and therefore it will have a different period.
Why a slightly different algorithm should have a different period?
BobInNJ wrote: If you need the same results on both C++ and Java, I strongly recommend that you implement your own random number generator.
That's not a good suggestion. As you probably know, writing a good random generator is not a simple matter. It is better (as suggested by Luc Pattyn) to use some technique to exploit the same number generator code or simply adapt an existing one.
BTW: Bob, did you find a bit irony in my OP, didn't you?
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]
|
|
|
|
|
When I wrote:
write your own random number gennerator
I meant that your application should define one not that you need to come up with your own algorithm
for one. I guess I was not clear about that.
Bob
|
|
|
|
|