|
Hello all
I am wrestling with a strange occurance in Visual C++ and being a newby to it I hope you guys can help.
What I have is 3 differant ways a usercan input the same data , either by a spin control, a slider bar or an edit control box. My goal is to have it where if one is adjused the others adjust as well. I have the code down for a change in the slider bar the edit and spin adjust to that value. If the editcontrol is box is used for entering data then both the sldier and the spinbox are updated as well
BUT when i try and build the function for the ON_SpinChange function I encounter a new problem. The code compiles just fine, however when i run it I get a gray box that pops up saying the following
DEBUG Assertion failed yadda yadda with 3 butons to IGNORE, RETRY or ABORT. and i do no know why this happens
the code for on SpinControlChange
is exactly the same as the OnEditControlChange , just differant data names.
here s the code for both
//on user inputting data into edit control box
void CTripCalculatorDlg::OnChangeEdit1()
{
CString SomeValue;
//value input into edit control = speed2
m_speed2.GetWindowText(SomeValue);
//Convert to an int
int speed2 = atoi(LPCSTR(SomeValue));
//adjust the progress bar position
m_progress.SetPos(speed2);
//adjust the slider bar position
m_slider.SetPos(speed2);
//Adjust the spinvalue
m_spin.SetPos(speed2);
m_spinvalue.SetWindowText(LPCTSTR(SomeValue));
} //THIS ALL WORKS FINE
//on input intothe spincontrol instead of using the spin arrows
void CTripCalculatorDlg::OnChangeSpeed()
{
CString SomeValue2;
//value input into spin control = speed
m_speed.GetWindowText(SomeValue2);
//Convert to an int
int speed = atoi(LPCSTR(SomeValue2));
//adjust the progress bar position
m_progress.SetPos(speed);
//adjust the slider bar position
m_slider.SetPos(speed);
//Adjust the editcontrol box
m_speed2.SetWindowText(LPCTSTR(SomeValue2));
}//THIS GIVES ME THE ASSERTION ERROR BOX
what is the differance betweent hese 2 codes that cause the assertion error?
i am perplexed
thank you in advance
Ed Storey
|
|
|
|
|
Where is the assert failing? When it fails, click Retry and the debugger will drop you at the failed assert. It's probably in MFC, so there should be comments there that explain what's wrong.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
--Buffy
|
|
|
|
|
Which line of code in OnChangeSpeed(..) is causing the assertion?
When you get the assertion, the message in the Abort/Retry/Ignore message box should tell you where the assertion is coming from. You can then track it back through the call stack.
Without knowing more about where the message is coming from and when you are receiving it, I would assume that it is coming off the initial dynamic data exchange operation when your dialog is being created. If this is the case, then you can try one (or both ) of:
Replace:
m_speed.GetWindowText(SomeValue2)
With:
if (::IsWindow(m_speed.GetSafeHwnd()))
{
m_speed.GetWindowText(SomeValue2)
}
Replace:
m_speed2.SetWindowText((LPCTSTR)SomeValue2)
With:
if (::IsWindow(m_speed2.GetSafeHwnd()))
{
m_speed2.SetWindowText((LPCTSTR)SomeValue2)
}
If this fixes your problem, then you will no that your routine is getting called before your control windows are actually getting created.
Ronald L. Russell Jr. (Ron)
rrussell@ygrest.com
|
|
|
|
|
ok the lines of code it does not like are similar to this one
_AFXCMN_INLINE int CProgressCtrl::SetPos(int nPos)
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, PBM_SETPOS, nPos, 0L); }
where the
ASSERT(::IsWindow(m_hWnd));
line exists.
I did what you suggested andthrew in a couple message box warnings to see where it goes BONK
I am guessing what is happening is that the code for OnChange is operating before the window is built. I can only assume the reason why this is happening is that when i declare the spin box my default value is 65 and so maybe at that moment it goes down to run this piece of code. However i can understand why it would do this because shouldnt the control box be fully built prior to the program running the onchange function.
i can onl assume i have to go into where i first declare the spinbox and its default value and throw the code in after this but this will only work then once on the initial loading and not if the user changes it later.
Or is there a way i can do this?
|
|
|
|
|
Note that the assertion is getting thrown because ::IsWindow() is failing in the CProgressControl::SetPos(..) member.
This tells you for sure that the progress control has certainly not been created the first time this function has been called.
Try the following:
Replace:
m_progress.SetPos(speed);
With:
if (::IsWindow(m_progress.GetSafeHwnd()))
{
m_progress.SetPos(speed);
}
Replace:
m_slider.SetPos(speed);
With:
if (::IsWindow(m_slider.GetSafeHwnd()))
{
m_slider.SetPos(speed);
}
With these modifications, you should not have to alter you architecture too much, and it should work as soon as the controls are created.
The code is being called before within the context of the dynamic data exchange function (i.e. your dialog's DoDataExchange(CDataExchange* pDX)). The first time this function is called, the controls have not yet been created, so the modifications I have suggested to not hurt you. Once the controls have been created and you can intereact with them, then the ::IsWindow() function will succeed for each and you should get the desired effect.
Ronald L. Russell Jr. (Ron)
rrussell@ygrest.com
|
|
|
|
|
I have seen several articles on various sites about how to prevent an application from showing on the taskbar. Can anyone point me at some information on how to hide an application from the tasklist as well?
|
|
|
|
|
This is a fragment of VB code I've found on the Internet. It is simple to understand and to port it to VC++. I didn't write this code, but I've tried it, and it works!
The author is Andrew Thomas
This is the original URL :
http://www.visual-statement.com/vb/Tips/dsk16.txt
By: Andrew Thomas
To hide your application from the task list,
you must register your program as a service.
This is done by passing the process ID of
your application to the RegisterService API.
Declarations
Copy the following code into the declarations section of a module:
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0
Procedures
To remove your program from the Ctrl+Alt+Delete list, call the MakeMeService
procedure:
Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub
To restore your application to the Ctrl+Alt+Delete list, call the
UnMakeMeService procedure:
Public Sub UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
End Sub
Don't forget to unregister your application
as a service before it closes to free up
system resources by calling UnMakeMeService.
|
|
|
|
|
Thank you for your response, but I am sorry I was not clearly describing what I am trying to do in my last post.
I am looking for a way, on Windows NT, to hide an application's icon from the ALT+TAB list. If anyone knows how this can be accomplished, I would appreciate the information.
Ronald L. Russell Jr. (Ron)
rrussell@ygrest.com
|
|
|
|
|
I want to have a background image for the List View Control,this list view control is inside a dialog(which is office 97 wizard - propertysheet).
I have set the background image for the dialog, using the constructor of wizard97 property sheet.
I wanted to have the transparency effect for the list view control, I tried setting the extended style option of transperency for the list view control,but it did not work.
So, I tried using SetBkImage function, so that i can have different bitmap for the list view control. But, the image is applied to the background of the dialog,(which is overriding the bitmap set using the c'tor of wiz97) instead of the list view control.
It would be great to have this working.
Thanks in advance.
Cheers
Kannan
|
|
|
|
|
How can I update resources under Windows 89/Me???
In the Win NT or 2000 it's very easy :
1.BeginUpdateResources
2.Update Resources
3.EndUpdaterResources.
But How can I make the same under Windows 89/Me???
|
|
|
|
|
I want to create a borderless window without title bar,I try
set the CreateWindow's parameter dwStyle to WS_VISIBLE only,but the window be created also have title bar and border.
thanks for any help!
by the way,pardon my poor english.
|
|
|
|
|
Basically, you want WS_VISIBLE | WS_POPUP. Here's some code (taken out of context) that I use. It will create a little rectangular window near the uppper left of your screen that is hard to see unless you throw in a little drawing code. From here, everthings up to you - title, border, menus, whatever.
m_wndSession is a class member derived from a CWnd. It it used to create a kiosk effect by sizing itself to the screen and overriding the ususal drawing fns.
This code just shows creation and makes it black so you can see it. (As I say, this code is out of context).
I register a new class here so I can get ownership of the device context, because this is a greedy and selfish window and definitely not a team player.
CString csWndClass = AfxRegisterWndClass(CS_OWNDC,
0,
0,
0);
if(!(m_wndSession.CreateEx(WS_EX_LEFT,
(LPCTSTR)csWndClass,
"Session Window",
WS_VISIBLE|WS_POPUP,
10,10,100,20,
NULL,
NULL
))) {
AfxMessageBox("Failed to Create Session Window)");
return;
}
CBrush cbr(RGB(0,0,0));
CDC* pDC = m_wndSession.GetDC();
pDC->SelectObject(cbr);
RECT rect = {0,0,1500,1500};
pDC->FillRect(&rect,&cbr);
m_wndSession.Invalidate();
...
|
|
|
|
|
how do i make a dialog hidden *before* it gets shown?
|
|
|
|
|
Is this a modal or modeless dialog? A hidden modal dialog makes no sense. You must therefore mean a hidden modeless dialog, which you can create without the WS_VISIBLE style.
|
|
|
|
|
Hi,
I'd like to to keep a database password inside a text file (similar to an INI file) to be used by my ANSI C++
program on Windows and UNIX. Naturally, I'd like to encrypt the password inside the file.
Do you know of a nice API or set of classes I can use for this?
Thanks a bunch!
Alvaro
|
|
|
|
|
Here is an exerpt from the readme file of Crypto++. There is a newer version too. The link is at the bottom.
--tale
---------------------------------------------------------
Crypto++: a C++ Class Library of Cryptographic Primitives
Version 3.2 3/20/2000
This library includes:
MD2, MD5, SHA-1, HAVAL, Tiger, RIPE-MD160, MD5-MAC, HMAC, XOR-MAC,
CBC-MAC, DMAC, DES, IDEA, WAKE, 3-WAY, TEA, SAFER, Blowfish, SHARK, GOST,
CAST-128, Square, Diamond2, Sapphire, RC2, RC5, RC6, MARS, Rijndael,
Twofish, Serpent SEAL, Luby-Rackoff, MDC, various encryption modes (CFB,
CBC, OFB, counter), DH, DH2, MQV, DSA, NR, ElGamal, LUC, LUCDIF, LUCELG,
Rabin, RW, RSA, BlumGoldwasser, elliptic curve cryptosystems, BBS, DEFLATE
compression, Shamir's secret sharing scheme, Rabin's information dispersal
scheme. There are also various miscellanous modules such as base 64
coding and 32-bit CRC.
You are welcome to use it for any purpose without paying me, but see
license.txt for the fine print.
Crypto++ has been compiled successfully with MSVC 6.0 on Windows 2000
and GCC 2.95.2 on FreeBSD 3.4.
Good luck, and feel free to e-mail me at weidai@eskimo.com if you have
any problems. Also, check http://www.eskimo.com/~weidai/cryptlib.html
for updates and new versions.
|
|
|
|
|
Hello,
I am building a simple program with VC ++ 6
I am using a dialog box to calculate the time it takes to finish a race in ideal time. (type in distance, input speed constant and click CALC then time should apear).
I am having a bit of trouble however converting the base 10 calculated time to real time. I get 1.5 instead if 1 hour 30 minutes. I was wondering if there are routings in VC that do this. Using integers it woul dnto be too bad I could mod 60 everything but I am dealing with floating point numbers and that is why I am stuck.
If you could help I would be greatly appreciated here
Thank you
|
|
|
|
|
Can anyone suggest me a tool to create AVI files for use with CAnimateCtrl, preferably one that allows to create 16 color AVIs?
|
|
|
|
|
Hi,
Can any expert tell me that how can I display the elapsing time once i have started the timer. It's should be something like a swatch watch. I need to know how to code the elapsing timer and to display it on the screen. I have done some coding that starts the timer and stops the timer, but that is in increment order, i need a decrement order timer function. I use the Pc system timer to implement the timer class. In my class i have included the folowing functions:
StartTimer()
EndTimer()
GetDuration()
Thank you for your help.
|
|
|
|
|
In what context.
Be a bit more specific.
Do you:
a. Need drawing code for the watch (swatch)
b. Or just need to know when the timer has elapsed.
Regards
Norm
|
|
|
|
|
I would like to know if there's a way to add checkbox in a CListCtrl view for each column
|
|
|
|
|
I am in the process of developing a custom desktop for Windows NT. In my implementation of this custom desktop, there is a window along the bottom of the screen that emulates the behavior of the Windows NT Taskbar.
This taskbar implementation sets a WH_SHELL hook and a WH_CALLWNDPROC hook to receive notifications concerning window creation, title changes, etc.
During the early portions of development, this custom shell was always ran on top of Explorer.exe. Eventually the custom shell was moved to a test system whose policy file (ntconfig.pol) directs windows to run the custom shell at boot time rather than Explorer.exe.
I have noticed that when this is the case, I no longer receive callbacks from the WH_SHELL hook procedure, although I still receive callbacks from the WH_CALLWNDPROC hook procedure.
I can launch Explorer.exe from the custom shell and I begin to receive callbacks from the WH_SHELL hook. I can even end the Explorer.exe task from the taskmanager, and I still receive shell hooks. It seems that Explorer.exe must at least run once before I receive any callback from the WH_SHELL hook.
I have discovered no information anywhere on MSDN that indicates that this is the case.
Does anyone have any information as to why an application would not receive WH_SHELL hook procedure callbacks unless Explorer.exe has been started at least once on a system?
|
|
|
|
|
When you do receive WH_SHELL callback, what process is the hook DLL in ?
|
|
|
|
|
Where can I find a decent corba IDL compiler for ms vc++ 6 ?
I found a couple of sites on the net but with all of them you need to install tons of junk before it works .... and then it still gives problems !!
|
|
|
|
|
I am wondering how those guys coded file/directory hiding in the "Magic Folders" program at the system level.
Is that some kind of file system driver ?
Any ideas?
|
|
|
|
|