|
Several problem areas here...
char *reply;
DWORD dwBytesTransferred;
DWORD dwCommModemStatus;
SetCommMask (hCom, EV_RXCHAR | EV_CTS | EV_DSR | EV_RLSD | EV_RING);
while (hCom != INVALID_HANDLE_VALUE)
{
SetCommMask (hCom, EV_RXCHAR | EV_CTS | EV_DSR | EV_RING);
do
{
res = ReadFile(hCom, reply, 81, &dwBytesTransferred, 0);
if (dwBytesTransferred > 0)
printf (reply);
} while (dwBytesTransferred == 1);
}
First, char* reply is only a pointer to a single character but you're trying to read 81 characters - you need a larger buffer. This is your real problem area.
Second, while not your problem, dwBytesTransferred is not initialized - you should always initialize your variables.
Third, while (dwBytesTransferred == 1) should be changed - if successful in this case, it will be 81. Perhaps you should say:
while (dwBytesTransferred > 0);
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
krmed wrote: char* reply is only a pointer to a single character...
A minor point here, char* reply does not point to a single character. It points to some unknown memory location, which the compiler thinks contains a character buffer.
INTP
Every thing is relative...
|
|
|
|
|
Thanks,
It actually worked when I changed it from a char pointer to a char array. But why would it work in this case if the pointer and the array could mean the same thing?
|
|
|
|
|
Using an array actually has memory allocated for the buffer, but the pointer is just a pointer - you have to allocate the memory yourself (and delete it when you are through.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Of course you are right. But then at my age I guess I'm allowed one brain fade after 11 consecutive days off!
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
The debugger’s expression evaluator could not obtain a value for the expression as written. One likely cause is that the expression refers to memory that is outside the program’s address space (dereferencing a null pointer is one example). Windows NT and Windows 95 do not allow access to memory that is outside of the program’s address space.
You may want to rewrite your expression using parentheses to control the order of evaluation
More Info ref-MSDN
regards,
Rajan
|
|
|
|
|
Hi All,
What I Need?
------------
I want to change the ToolButton's image with respect to different conditions.
What I did?
-----------
I creatd mfc application with ToolBar. And i added UI Command handler to the target ToolBar Button. In that handler i called CToolBar::SetButtonInfo() to change the button image into new one which i drawn.
What Stoped me?
--------------
After this step i saw my target ToolButton image is blinking. And also when pass the mouse pointer over ToolBar buttons, All buttons stops ToolTip popup.
What could be the possible reason to this??
Thanks n regards,
Rajan
"What Happened to a man is less signigicant than what happened inside him"
|
|
|
|
|
rajan4008 wrote: And i added UI Command handler to the target ToolBar Button. In that handler i called CToolBar::SetButtonInfo() to change the button image into new one which i drawn.
LOL What are you trying to do buddy. Why do you do this in the UI command handler. Everytime the UI is updated the Image will be reset. Hence I think the blinking.
Note: UI handlers must always try to use CCmdUI object to deal with UI updation. AFAIK you never know when it will be called. So it's safe to use the CCmdUI object. And don't try to do anything else.
You can use SetButtonInfo in the OnCreate function for the frame.
rajan4008 wrote: After this step i saw my target ToolButton image is blinking
OT: Now I know how to blink a toolbar button...He he;P
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Hi Buddy,
I wanna change image of ToolButton based on some condition. More clearly, My App has TreeView item. When user selects Target Item from the TreeView Items then i, wanna change image of my ToolButton. I have drawn 2 images-One is set as default and another one is set based on TreeView Item contents.
As you told, I already added SetButtonInfo() in Frame's OnCreate().However, if user selects something from TreeView which changes ToolButton's colour and he deselects the item then i, need to show the item as default image. Hence, I did SetButtonInfo() again in OnUpdateButtonxxxx().
For Instance:
void CMainFrame::OnUpdateButtonxxxx()
{
// Check wheather TreeView Item is Selected
theApp.ToggleButton();
}
void CMyApp::ToggleButton()
{
if(UserSelctedTreeViewItem)
SetButtonInfo(TOOLBUTTON_IND, XXXX, PUSHBUTTON, GREEN);
else
SetButtonInfo(TOOLBUTTON_IND, XXXX, PUSHBUTTON, GRAY);
}
NOTE: ToolTip is blocked due to this code. That's my major problem.
Some of My Doubts are:
1.If SetButtonInfo() is called with same ID then does it stop ToolTip? if yes how?
2.I accept that due to calling SetButtonInfo() again and again in the OnUpdateButton() Handler i'm getting blinking image. But it is not happening when i change the resource ID and also i'm getting ToolTip.
3.To achieve dynamic image toggling where should we call SetButtonInfo()?
Thanks in Advance,
Rajan
|
|
|
|
|
There are notification messages for this purpose.
Suppose you wanna handle selection change event then do this. (Write this in the parent window)
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnNotifySelChange)
in .h file
afx_msg void OnNotifySelChange(NMHDR* pNm, LRESULT *pRes);
in .cpp file
void CYouparentClass::OnNotifySelChange(NMHDR* pNm , LRESULT *pRes)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
}
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I want to create a time delay about 1/20 milisecond.
|
|
|
|
|
You can use QueryPerformanceCounter().
|
|
|
|
|
hai do u know assmbly language.
if u know 8086 assm lan Easily you can create a time delay
|
|
|
|
|
You probably can't reliably without going to extrodinary means. This is because Windows is not a Real time operating system, and at any stage your process could be preempted. However, the closest you can get is by calling
::Sleep(20)
In reality this will sleep more than twenty milliseconds quite often, because it relinquishes your timeslice in the process scheduler, but it is the best you can do without doing something really hard.
Despite what my mis-spelling co-poster tells you, going to assembly language will not offer you any benefit over the above, because it is no less subject to pre-emption than anything else. He/she might argue that you do not relinquish your timeslice as above, however the same can be accomplished in C++ too.
For example:
class Timer
{
public:
Timer();
void wait(DWORD ms);
private:
static int cyclesPerMs; // Number of loop iterations per millisecond
};
int Timer::cyclesPerMs = -1;
Timer::Timer()
{
const CALIBRATION_TICKS = 100000;
if(cyclesPerMs == -1)
{
// Calibrate timer
clock_t start = clock();
for(int i=0; i
|
|
|
|
|
What do you need the delay for?
Don't try it, just do it!
|
|
|
|
|
Hi,
My query is MFC related to Dialog box.
I want to change the Text property label of parent dialog box from its child dialog file.
How to change Text lable of parent dialog box from its child dialog file?
Thanks in advance
-Ramesh.
|
|
|
|
|
Use GetParent() from the Child Dialog.
GetParent()->SetWindowText("New title");
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thanks,
But how to specify the Parents perticular Text property ID to change its lable from its child dialog file.
-Ramesh
|
|
|
|
|
Didn't get you. Be more clear. May be an illustration would do.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I have a Text control on parent dialog box its ID is say IDC_TEXT1 & its Caption is "MY NAME". I want to change its caption from its another child dialog box file. When I click on child TAB page then parent IDC_TEXT1 caption should change to "NEW NAME".
Thanks
-Ramesh
|
|
|
|
|
((CYourDialogClass*)GetParent())->GetDlgItem(IDC_TEXT1)->SetWindowText("NEW NAME");
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thanks
I have already tried that, but Child dialog box file not getting patent Text ID
Is it possible to use Notification message from child to parent to change the parent Text property caption.
If it is possible, Please let me know.
|
|
|
|
|
Is the child dialog a model dialog or modeless dialog ?
If its a modeless, did you pass the the parent window to the modeless dialog ?
-Prakash
|
|
|
|
|
It is Modal dialog box.
ya, I have passed the parent window to the modeless dialog
Thanks
-Ramesh
|
|
|
|
|
I want to read value of address 0000:0408 to check port LPT1. But there is error when I run this program.
How to read value of that address ?
|
|
|
|