|
Christian Graus wrote: What on earth is a TEdit ?
I think it's Borland's version of CEdit .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can you tell me what is TEdit for read a file you can use of CFile class.
|
|
|
|
|
hey folks,
i stumbled across an assertion in my program. When I want to show a dialog modally the dialog is shown correctly, but when I close the dialog I get an assert:
"Debug assertion failed! ... program ...wincore.cpp line 882" which is:
void CWnd::AssertValid() const
{
if (m_hWnd == NULL)
return;
ASSERT(HWND_TOP == NULL);
if (m_hWnd == HWND_BOTTOM)
ASSERT(this == &CWnd::wndBottom);
else if (m_hWnd == HWND_TOPMOST)
ASSERT(this == &CWnd::wndTopMost);
else if (m_hWnd == HWND_NOTOPMOST)
ASSERT(this == &CWnd::wndNoTopMost);
else
{
ASSERT(::IsWindow(m_hWnd));
My code is farely simple:
CSelectionDlg dlg;
dlg.DoModal();
the thing is: I call this from a member-class:
-MyDialogDlg my dialog
-SomeClass m_instanceOfClass; a memberclass of dialog.
a function of Someclass does the above code
I found some stuff from microsoft:
http://support.microsoft.com/kb/194300/eng
which didn't work for my case!
if I add
ASSERT(::IsWindow(m_hWnd)); before the domodal nothing changes... so somehow my handle gets lost and I donnu what to do. can anybody help? maybe a simple link. i tried many links, although nothing worked for my case. I don't have any crazy stuff in my OnInit of the dialog nor do I have another dialog as model dialog
thx for your help
zqueezy
|
|
|
|
|
Did you try to trace your code line to line it seems you have a unvalid hwnd on your code.
|
|
|
|
|
well, as I said, the handle is valid before the DoModal-call! but somehow not during it
|
|
|
|
|
I would expect your ASSERT placed before the DoModal() to succeed, it just means that you are calling DoModal() from a CWnd derived class that has a valid Window, it has no bearing on the state of the dialog.
Are you calling DestroyWindow() somewhere in your Dialog class?
|
|
|
|
|
A easy to read time delay code in c++. What i can't understand is the role of clock() in the while loop where: clock()-start < delay. However i know the role of clock() in the program and i know the result of eliminating clock() in the while loop.But:
WHY CLOCK() - START ? clock() is as the same as the start and there is a type cast a line before , or i'm far far off the way ? Thanks
#include<iostream>
#include <ctime>
using namespace std;
int main()
{
cout << "Enter the delay time, in seconds: ";
float secs;
cin >> secs;
clock_t delay = secs * CLOCKS_PER_SEC; // convert to clock ticks
cout << "starting\n";
clock_t start = clock();
while (clock()- start < delay ) // wait until time elapses
; // note the semicolon
cout << " done\n ";
cin.get();
cin.get();
return 0 ;
int life()
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
Im not sure what you're asking ...
(1) clock_t start = clock();
(2) while (clock()- start < delay ) // wait until time elapses
at 1, start = t0
at 2, clock() is tn, that is, time increasing by whatever the resolution of clock() / the processor is running at
so in theory, no, clock() != start, clock() must be greater than start
Its not the most efficient way of delaying though .....
|
|
|
|
|
I think i just don't understand how all this hanging on
start = t0 and clock= tn but if start = clock() is an assignment so how could start = 0 ? becouse the clock() returns a value ( the time elapsed until now) to the start.
i try to read more about it on net and my book but i'm stil confused. No matter it's a important part of programming or not i don't like to read something and just move to the next chapter.
int life()
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
pourang wrote: What i can't understand is the role of clock() in the while loop
clock() does the same thing whether it is in a loop or not.
pourang wrote: clock_t start = clock();
while (clock()- start < delay ) // wait until time elapses
; // note the semicolon
Each time this loop executes, the difference between clock() and start increases (by some small amount). While that amount is less than delay , the loop continues.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks.
Nice , I got it.
int life()
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
I am trying to learn C++. I am trying to write a program that will allow a 5 digit number to be input and then print the digits seperated by three spaces. I have the following, but when I try to compille it I am getting an error. I would defenitely appreciate any help.
#include
using std::cout;
using std::cin;
using std::endl;
int main();
{
a = number1 / g%;
b = a / g%;
c = b/ g%;
d= c/ g%;
e = d/g;
g = 10
cout << "Enter a five digit number : ";
cin >> number 1;
cout << "a b c d e" << endl;
system("PAUSE");
return 0;
}
keep getting the following errors, when trying to compile the program
How would I fix this?
expected ';' unqualified-id before ‘{‘ token
expected ’;’ or ‘;’ before ‘{‘ token
getting that error on line 8
jada 23
jada 23
|
|
|
|
|
Remove the semicolon after main()
|
|
|
|
|
jada0923 wrote: How would I fix this?
After fixing main() 's signature, you'll then be presented with at least 13 more errors. Just where did you get this code from?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Dear kind peoples, I am working on a project and have been having a hard time getting rid of these
memory leaks here. Could someone tell me what I am doing wrong?
CASE #1
#define MAX_DICT 4096
Lzss::Lzss( void)
{
m_pDad = ( int *) ::malloc( ( 3 * ( MAX_DICT + 1) + 256) * sizeof( int));
}
Lzss::~Lzss( void)
{
free( m_pDad);
}
CASE #2
typedef struct s_PageDesc
{
.....;
LPDIRECT3DTEXTURE8 pTexture;
....;
} DXARTPAGEDESC,*LPDXARTPAGEDESC;
LPDXARTPAGEDESC m_pPageDesc;
UINT m_uMax; // number of pages
----Created Here----
m_pPageDesc = (LPDXARTPAGEDESC) realloc (m_pPageDesc, m_uMax * sizeof(DXARTPAGEDESC));
....
----Destructor----
for (UINT i = 0; i < m_uMax; ++i)
{
SAFE_RELEASE (m_pPageDesc[i].pTexture);
}
free (m_pPageDesc);
m_pPageDesc = NULL;
|
|
|
|
|
In case #1, what's leaking? If every malloc() call has a corresponding free() call
then there should be no leaks.
In case #2, if you only use realloc(), make sure that m_pPageDesc is set to
NULL before the first realloc() call.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ah, you're learning not to do kiddies homework....LOL
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i have to create a popup menu at runtime, the menu's items have the same message-handler function so i can use the ON_COMMAND_RANGE(id1, id2, memberFxn) macro, but i dont know the id-range, because i retrieve it at runtime as said
|
|
|
|
|
can you show how do you create the menu items ? May be I'll find a suggestion to solve your problem.
|
|
|
|
|
I have a trivia question for you CStatic wizards out there.
Given a CStatic as created in a dialog displaying a bitmap, it lives for the lifetime of the dialog object. In my cleanup code, I have to release allocated resources - bitmaps being one of them. How does one tell a CStatic control to not use a bitmap, is it as simple as calling SetBitmap(NULL)?
What I want to do is make sure I don't delete a GDI object while it is in use, and I would think that CStatic would have it in use.
thanks
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
Overheard in a cubicle: "A project is just a bug under development."
Seeking to rise above the intelligence of a one eared rabbit...
Caught in a vortex of weirdness...
|
|
|
|
|
Generally if you set a bitmap at runtime, you would want to restore the
bitmap at runtime.
In this case, you should store the previous bitmap (returned by the first
CStatic::SetBitmap()/STM_SETIMAGE) and restore this when you're done with
the control. This value may very well be NULL, but it's your responsibility to put
it back or track it's lifetime.
This is from the docs:
Important
In version 6 of the Microsoft Win32 controls, a bitmap passed to a static control
using the STM_SETIMAGE message was the same bitmap returned by a subsequent
STM_SETIMAGE message. The client is responsible to delete any bitmap sent to a
static control.
With Microsoft Windows XP, if the bitmap passed in the STM_SETIMAGE message
contains pixels with non-zero alpha, the static control takes a copy of the bitmap.
This copied bitmap is returned by the next STM_SETIMAGE message. The client code
may independently track the bitmaps passed to the static control, but if it does not
check and release the bitmaps returned from STM_SETIMAGE messages, the bitmaps
are leaked.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
insert forehead slapping sound...
of course, the returned HBITMAP. Duh.
Thank you also for the other warning info.
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
Overheard in a cubicle: "A project is just a bug under development."
Seeking to rise above the intelligence of a one eared rabbit...
Caught in a vortex of weirdness...
|
|
|
|
|
Hi,
I download a '.bmp' file through internet and save bits in the heap like char*, can I create CBitmap without save file to disk.
|
|
|
|
|
Is CBitmap really what you want? CBitmaps are device-depentent bitmaps (DDB)
while a .bmp is device independent bitmap (DIB).
You can convert bitmaps from whatever type to whatever other type, but you
need to specify what type you want the resulting bitmap to be.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|