|
Hi Padelis,
Good looking code. Some things you need to check:
1.) The line va_arg(arg,short) describes the passed arguments as datatype short. Check your code and make sure that your only sending shorts, you may have accidently passed a BYTE or an int.
2.) It looks like BDM_NOTREADY is the argument terminator value. When the arguments are passed to this function BDM_NOTREADY should be the last value. Such as: "1,2,3,4,5,BDM_NOTREADY". Make sure this is whats happening.
3.) I see a call to response = bdm_clk (cmd, CommandBitCount); outside of the while loop. The result of this call would be removing the first argument from the list without being processed or checked for error. If the first value is BDM_NOTREADY this may cause va_arg to increment past the end. Is this the intended behavior?
Some documentation:
va_arg, va_end, va_start[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
David, may I ask if you are a professional programmer???? Till now you have helped me a lot and you solved all my problems till now! You are great. Wish i had someone to teach me again!!
Once again you were right about the va_arg! I was sending a few BYTES!! My mistake!! As soon as i corrected it, it worked!! But after a while i changed something, don't remember what, and it stopped!
Still scratching my head on what happened! Because i am using some old sources files and updating them, it seems that i will need to completely rewrite some of the functions. The problem appear on the read function which i need to rewrite. I have to read data from parallel and save to a file.! I will not give up till i have it completed!
|
|
|
|
|
Hi Padelis,
psychegr wrote: David, may I ask if you are a professional programmer???? Till now you have helped me a lot and you solved all my problems till now! You are great.
Thanks for the compliments. I have been programming since the early 1980's.
psychegr wrote: Once again you were right about the va_arg! I was sending a few BYTES!! My mistake!! As soon as i corrected it, it worked!! But after a while i changed something, don't remember what, and it stopped!
I recommend that you make a Zip backup each time you have success. I also do this sometimes when I make big changes to projects. Its only 10 seconds to right-click and make a zip file.
psychegr wrote: I will not give up till i have it completed!
Excellent, I like your attitude.
Best Wishes,
-David Delaune
|
|
|
|
|
Early 80s? I was born in 1984!!
I figured out the va_arg mistake now and it is ok.
Currently i have done a lot in this app.
I have managed gain access to parallel port without use of allowio.exe and recognise the hardware!
I have made the basic protocol communications like reset, run and stop!! The mcu connected to the hardware goes into reset, runs and stops.
So far so good! Now i am trying to read the contents of the mcu. The problem is that i have read some bytes from the ecu but all were FFFFs!!! This is not correct! And the time that it does to read 10 addresses is 45 minutes. This is too long. Also my app consists from a Main Form Window with buttons and everything else, and a console window which informs the user with what is happening. When i push the Read button the from window hangs (not responding) but the console window doesn't. The app reads the mcu and this is what it is shown in the console window and when everything finishes the Main Window becomes available again. What could be wrong??? Also is there a way to insert the console window in my Main Window? The console window is the old known console window! Any thoughts??
Also, David have you ever tried to do something similar to what i am doing now?
|
|
|
|
|
Hello guys im trying to learn C and below i have a simple program that keeps reading charachter until the EOF (End of File) Charachter is read.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int c;
while((c = getchar()) != EOF)
{
putchar(c);
}
printf("\n");
printf("%3d \n",EOF);
system("PAUSE");
return 0;
}
Can you please what type of charchter the EOF file is or maybe explain exactly what it is maybe im not understanding. Thank you very much
|
|
|
|
|
Hi,
cdpace wrote: that keeps reading charachter until the EOF (End of File) Charachter is read.
is not accurate. The end-of-file is not stored as some special character; the file or directory has a length stored somewhere, and getchar() returns characters as long as the file length has not been exceeded; when all data has been returned, the special value "EOF" is returned.
So EOF is NOT a character, it is a special integer value outside the regular character range [0,255], and that is exactly why the return type of getchar() isn't char. Usually EOF equals -1.
But that really is an implementation thing, other platforms might use a different special value; the C specification mandates that the symbol EOF works as documented, without fixing a specific value.
|
|
|
|
|
Something I like to add here.
In the DOS/WINDOWS character set, character 26 (^Z)(Control + Z) is assigned as the end of file character for text files.
When we issue the copy con command at the dos prompt, we type text and to terminate we press ^Z.
Take this case.
Consider a binary file of XXX bytes length having the 5th byte as character 26 (Hex: 1A).
Now open the file in text mode - fopen("file", "r");
When you try to read XXX bytes using fread , it will read only 4 characters. (Till character 26).
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: In the DOS/WINDOWS character set, character 26 (^Z)(Control + Z) is assigned as the end of file character for text files.
Ctrl+Z is not stored in the file.
«_Superman_» wrote: When we issue the copy con command at the dos prompt, we type text and to terminate we press ^Z.
Ctrl+Z was a special key combination used by copy (and other things borrowed from DEC) to know when to end copying from the console.
"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
|
|
|
|
|
DavidCrow wrote: Ctrl+Z is not stored in the file.
Agreed. But if it does exist in a file, many command will consider that as EOF.
Assume the following file contents -
A B C D E F ^Z G H I J K L
Executing a type command will only output till F.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I want to have the user click on a MDIchild window frame to resize it, but when you set the frame to WS_THICKFRAME, to get the resizable frame, then the OnNcLButtonDown() event is not seen. I just want to capture the mouse up so I know when the resize should stop. There must be a way to do this.
|
|
|
|
|
In the OnSize handler, check if the left mouse button is down - GetKeyState(VK_LBUTTON)
Now do a SetCapture .
You should now be able to get a WM_LBUTTONUP .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi, thanks for the response. I tried this and it does detect the WM_LBUTTONUP, but somehow it lost the ability to stretch the frame. After clicking on the frame dragging the mouse doesn't move the frame.
|
|
|
|
|
You're probably not calling the base class implementation of OnSize .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yes, I am calling the base class too. See code below:
void CImagrView::OnSize(UINT nType, int cx, int cy)
{
static bool cap = false;
ATLTRACE2("*****"__FUNCTION__"\n");
if (m_resizing && GetKeyState(VK_LBUTTON) && !cap) {
SetCapture();
cap = true;
}
CScrollView::OnSize(nType, cx, cy);
}
The call to SetCapture is stopping the frame from being stretched. I put in a static flag to only call SetCapture the first time. Then the frame stretch works again, after you release the mouse, but then the ButtonUp is back to not being detected again.
If I change the window to not have WS_THICKFRAME, then it can detect the NcLButtonDown and Up.
|
|
|
|
|
Hi,
I try to implement a combobox where it is possible to delete items in expanded state (listbox portion of combobox is dropped down). Here what I have done: I added a keyboard handler and call DeleteString(GetCurSel()) . Unfortunately the height of the listbox is never updated after items are removed. I tried to call ShowDropDown(FALSE); ShowDropDown(TRUE); as a workaround, which will update the listbox size... but it comes with an animation on Windows XP (Common Controls 6).
1) Is there a way to disable animations for a specific control?
2) Alternatively, can I get access to the listbox portion of a combobox in order to manually update its size?
Thanks for help!
/M
|
|
|
|
|
Apparently CComboBox::GetComboBoxInfo[^] can give you a handle to the list control. Aside i would try to use GetItemHeight/SetItemHeight to see if it triggers any size recalculation in the control or not, maybe you get lucky. Another thing you could try experimenting with is CWnd::SetRedraw, you could try to disabe redrawing of the whole window, do your ShowDropDown routine and then re-enable redrawing and have the list get redrawn. I might be reinventing the wheel here but i think you can't disable animating for a single control, only for the whole system.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Code-o-mat wrote: Apparently CComboBox::GetComboBoxInfo[^] can give you a handle to the list control.
Thanks that helped! A more detailed answer in the post below.
/M
|
|
|
|
|
Hei Moak,
See if this works:
COMBOBOXINFO cbi = {sizeof(COMBOBOXINFO)};
if(GetComboBoxInfo(&cbi))
{
HWND hwndListBox = cbi.hwndList;
LRESULT lNum = SendMessage(CB_GETCOUNT,0,0);
LRESULT lWidth = SendMessage(CB_GETDROPPEDWIDTH,0,0);
LRESULT lHeight = SendMessage(CB_GETITEMHEIGHT,0,0);
::SetWindowPos(cbi.hwndList,0,0,0,lWidth,lNum+1 * lHeight,SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}
|
|
|
|
|
Great this works! I changed the code slightly, CB_GETDROPPEDWIDTH returned zero.
COMBOBOXINFO cbi = { sizeof(COMBOBOXINFO) };
if(GetComboBoxInfo(GetComboBoxCtrl()->GetSafeHwnd(), &cbi))
{
CRect rect;
::GetWindowRect(cbi.hwndList, &rect);
rect.bottom = rect.top + GetCount()*GetItemHeight(0) + 2;
::SetWindowPos(cbi.hwndList, 0, 0, 0, rect.Width(), rect.Height(), SWP_NOMOVE | SWP_NOZORDER);
}
There are two thing I am not sure about and I would like to ask: In the height calculation I needed to add 2 pixels for the border, is there a better alternative than using a magic value? About the flags for SetWindowPos() , I didn't understand from MSDN what SWP_NOOWNERZORDER [^] is for? I replaced it with SWP_NOZORDER , hope this is okay.
Thanks, M
|
|
|
|
|
Moak wrote: There are two thing I am not sure about and I would like to ask: In the height calculation I needed to add 2 pixels for the border, is there a better alternative than using a magic value?
I am actually not sure about this. I do not know if the GetSystemMetrics Function[^] will return anything meaningful for the ListBox border. You can check if SM_CYFIXEDFRAME returns the correct value. Interestingly enough I did not have this problem... Hmmmm GetCount() returns a zero based index... shouldn't you be adding 1 before multiplying by height?
Moak wrote: I didn't understand from MSDN what SWP_NOOWNERZORDER [^] is for? I replaced it with SWP_NOZORDER, hope this is okay.
Oops, yes... SWP_NOZORDER is correct...
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: You can check if SM_CYFIXEDFRAME returns the correct value. Interestingly enough I did not have this problem
Okay, I will check it tomorrow. Btw, GetCount()[^] returns not a zero based index.
Thanks again... time to get some sleep.
|
|
|
|
|
Moak wrote: Btw, GetCount()[^] returns not a zero based index.
Ahhh yes you are correct again.
Its the CB_GETCOUNT Message[^] that returns the zero based index.
Best Wishes,
-David Delaune
|
|
|
|
|
To know the size of the border you could try this trick:
CRect Outer, Inner;
list.GetWindowRect(&Outer);
list.GetClientRect(&Inner);
list.ClientToScreen(&Inner);
int LeftBorder = Inner.left - Outer.left;
int TopBorder = Inner.top - Outer.top;
int RightBorder = Outer.right - Inner.right;
int BottomBorder = Outer.bottom - Inner.bottom;
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
A window called GetCapture() first, then calls ReleaseCapture() when mouse-down (on WM_LBUTTONDOWN message).
If mouse-down is not clicking on the window, how do we dispatch WM_LBUTTONDOWN message to that window clicked?
The question is similar to Window's menu - WM_LBUTTONDOWN is correctly dispatched if clicking outside of menu, acturally the window I asked is similar to menu for displying some information.
|
|
|
|
|
Convert the position given in the WM_LBUTTONDOWN message to screen co-ordinates. Use GetWindowFromPoint to get the window at that position. Post the WM_LBUTTONDOWN message to that window, remembering to convert the screen co-ordinates to client co-ordinates for that window.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|