|
But why a shared text file? Is there some particular reason for that? As i see it this would work fine with simply using a TCP/IP connection or UDP or somesuch to send and receive commands, don't know what is available under iOS though. Anyways, if you do insist on the shared file thing then you could try looking into a samba implementation (or there was some kinf of web-based file share protocol, but can't recall the name, webdev or something similar), i have seen software using samba on iOS so that should be possible (maybe there are libraries for it?).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Your best bet should probably be to look up inter-process communications[^] and pick one that fits your situation best. If you have two different systems with two different operating systems, your best bet is to use sockets.
|
|
|
|
|
Dear Developers,
I am using a list control. We are developing a demo version of our product and I want to restrict header click because the items getting sorted.
I have handle HDN_ITEMCLICK event and return at it's very first(if it's a demo version). I have also tried to set *pResult = 1, but both are not working.
Can anyone help me to bring me out.
Thanks.
Amrit Agrawal
|
|
|
|
|
Amrit Agr wrote: ...I want to restrict header click because the items getting sorted.
Can't you just add the LVS_NOSORTHEADER style?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 24-Mar-12 18:28pm.
|
|
|
|
|
But when I have set extended styles of List control, I have not added LVS_NOSORTHEADER style. The code of set extended style is here.
m_lvwTopics.SetExtendedStyle(LVS_EX_ONECLICKACTIVATE|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
Thanks.
|
|
|
|
|
Use Spy++ to see what styles that control has.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I am developing a program with VS2005 which will work on a keyboard only system. And I want to set focus on an activeX(Textbox) when the dialog show up. I use the m_textbox.SetFocus() in the OnTimer() function, but the focus stays on the OK button. And then, using code:
CWnd* pw=GetDlgItem(IDC_TEXTBOX1);
pw is NULL.
When I tried this in the VC++6.0 environment, The focus can be set successfully.
Any suggestion? Thanks.
modified 23-Mar-12 10:21am.
|
|
|
|
|
|
With each passing day, I keep feeling like I'm taking 2 steps forward and 1.9 steps backward. I'm not sure what that 0.1 step is telling me, however.
On a dialog, when I right-click a control, I'm wanting to display a list control with images (not bring up a second modal dialog with those images). When an image is selected, or if the list control loses focus, I want it to close. My first go at this was to derive a class from CListCtrl , and display it dynamically. Other variations of this exist on the web, and as a matter of fact I am using some of them elsewhere in my project. The only difference being none of them are derived from CListCtrl . With that in place, the list control displays and I can interact with it. When an item is selected, I get an NM_CLICK notification and can close the list control. The problem is closing the list control when it loses focus, either because I tabbed or mouse-clicked elsewhere. No other messages (e.g., WM_KILLFOCUS , WM_ACTIVATE , WM_LBUTTONUP ) are sent during these events, nor is PreTranslateMessage() called.
My second approach was to instead derive a class from CWnd , with a CListCtrl member variable. The window and the list control displays and I can interact with it (I say "it" because the list control completely covers the window). In addition, message handlers such as OnActivate() , OnKillFocus() , and OnLButtonUp now get called as well as PreTranslateMessage() . When and how these get called depend on how SetCapture() is called.
If I call it in the context of the CWnd object, the message handlers get called. When an item in the list control is selected, OnLButtonUp() is called and I can close the list control. The problem is that it is also called when I click the scroll bar. If I call it in the context of the CListCtrl object, some of the message handlers and PreTranslateMessage() get called. Now when an item in the list control is selected, PreTranslateMessage() is called with WM_LBUTTONDOWN and I can close the list control. The problem is that it is also called when I click the scroll bar. Both of these approaches require a little bit of client-to-screen and point-in-rect fiddling, but I *think* it's possible.
At this point, I'm confused as to exactly what I have. Neither approach gets me exactly what I'm after, and I feel like I'm having to put too much code in it to do what is otherwise easy when dealing with a CListCtrl object on a dialog template. I'd much prefer the first approach as it seems a bit cleaner, but I'm not against the second approach if I didn't feel like the "hidden" window was getting in the way.
Having said all of that, am I completely doing something wrong, or just mising some little piece that would sew it all up nicely?
Thanks.
- DC
[edit]
I made a bit of progress today by subclassng both CWnd and CListCtrl (before I was just using a native CListCtrl object). Now I'm able to intercept various messages in the list control class. The list control is opening and closing as expected. So far so good...
[/edit]
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 23-Mar-12 12:03pm.
|
|
|
|
|
I would use the second approach because it separates handling of the window (loose focus, mouse clicked outside, ESC/TAB pressed) from the list itself.
If clicking the scroll bar is your only problem, the solution is simple:
If the point is inside the client rect of the list control, you clicked the list, otherwise you clicked the scroll bar when inside the list controls window rect (the parent window client rect when using the second approach).
|
|
|
|
|
Jochen Arndt wrote: If clicking the scroll bar is your only problem, the solution is simple: If the point is inside the client rect of the list control, you clicked the list, otherwise you clicked the scroll bar when inside the list controls window rect (the parent window client rect when using the second approach).
Yeah, I already had that detail worked out. The problem is that a slow, single click on the scroll bar is ignored. If, however, I single click almost to the point of it being a double click, the scroll bar will respond.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Then there is something not OK with the command handling. Did you handle that in the WM_LBUTTONDOWN handler? Because scroll bars act upon button down.
Where did you handle the message (CWNd or list control) and how did you pass it to the scroll bar? For the list control, just call the default handler which will pass the message to the scroll bar.
|
|
|
|
|
Hey Guys,
I ran into a frustrating problem yesterday. I've been using winsock2.h and Afxwin.h to create asynchronous TCP/IP sockets in C++ for awhile (I'm using Visual Studio).
I've also been using Arduinos to deliver sensor data over serial to C++ programs via the Arduino SerialClass (http://arduino.cc/playground/Interfacing/CPPWindows).
I tried combing the two functions yesterday into something that could send serial data over TCP/IP but soon discovered that adding afxwin.h library to my existing serial port reader led to the following error:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
If I remove the windows.h definition from the arduino class I get 81 errors describing things like missing semicolons and undeclared identifiers in the serialclass (the library works fine normally).
I've tried changing the MFC settings in visual studio to work with windows libraries, but I get this error instead:
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
I've tried #define _AFXDLL, which gives the 'windows.h already included' error again.
Does anyone know a way to make these two headers work with each other so I can integrate the functionality? If not I guess I need to find a way to either
1) Read the serial port without the Arduino SerialClass and windows.h (is that possible?)
2) Broadcast TCP/IP messages without winsock2.h & AFxwin.h
Any help appreciated, I'm rather stuck!
I also can't switch operating system due to the nature of numerous other components in this project.
Thanks,
Ad
|
|
|
|
|
Remove all include statements from the SerialClass.h header file and place them in the SerialClass.cpp file. When using pre-compiled headers in your project, replace the include statement for afxwin.h by stdafx.h which includes afxwin.h.
|
|
|
|
|
Hi Jochen,
Thanks for the reply. I can't seem to get it to work though. Sorry, I'm pretty lame at anything but basic coding.
The Arduino SerialClass comes as SerialClass.h and Serial.cpp You can see them here http://arduino.cc/playground/Interfacing/CPPWindows[^]
I have a seperate file Serial_Client.cpp that holds my main() and stdafx.h.
I moved the include statements to Serial.cpp but this no longer compiled (I've taken out the #include winsock2.h and afxwin.h, just as a test). So I created a SerialClass.cpp and put them in there, but I had the same problem.
Was I supposed to put the moved #includes in Serial.cpp file (the class source code) or somewhere else?
Thanks a lot.
|
|
|
|
|
Because you are using stdafx.h, I assume that you are using pre-compiled headers (which is the default for VS projects).
When using pre-compiled headers, every cpp file must include the stdafx.h file before any other header files. Doing so, the standard windows and MFC definitions are present when the compiler processes other header files and the code.
As a general rule, the project specific header files should only include other header files that are necessary to compile the header file (containing definitions that are used in the header file). When including stdafx.h as first file in every cpp file, the common windows header files are already included when processing the other header files.
But your original SerialClass.h file includes header files that are also included by stdafx.h.
Please include stdafx.h as first one in all cpp files, remove all include lines for afxwin.h and windows.h from all cpp and header files (except stdafx.h) and try to build the project. If there are still errors, post them here.
|
|
|
|
|
Thank you for that excellent explanation! I tried what you suggested and also moved all my #includes (from all the .cpp's and .h's) into stdafx.h. It compiled fine, even with winsock2.h included in stdafx.h.
I am having some problems now trying to use any of my existing sockets code but I think it's a linker error that should be resolvable (as Google seems to hint). I've been using a header defined class 'CIPMessage' (from Boby Thomas P's excellent article Chat Client Server[^]) to define an object that handles all the sockets communication. Creating this object gives the following errors:
Serial_Force_Client.obj : error LNK2028: unresolved token (0A0003A1) "public: __thiscall CIPMessage::CIPMessage(void)" (??0CIPMessage@@$$FQAE@XZ) referenced in function "void __clrcall `dynamic initializer for 'MyMessObj''(void)" (???__EMyMessObj@@YMXXZ@?A0x282c2107@@$$FYMXXZ)
1>
Serial_Force_Client.obj : error LNK2028: unresolved token (0A0003A2) "public: __thiscall CIPMessage::~CIPMessage(void)" (??1CIPMessage@@$$FQAE@XZ) referenced in function "void __clrcall `dynamic atexit destructor for 'MyMessObj''(void)" (???__FMyMessObj@@YMXXZ@?A0x282c2107@@$$FYMXXZ)
1>
Serial_Force_Client.obj : error LNK2019: unresolved external symbol "public: __thiscall CIPMessage::CIPMessage(void)" (??0CIPMessage@@$$FQAE@XZ) referenced in function "void __clrcall `dynamic initializer for 'MyMessObj''(void)" (???__EMyMessObj@@YMXXZ@?A0x282c2107@@$$FYMXXZ)
1>
Serial_Force_Client.obj : error LNK2019: unresolved external symbol "public: __thiscall CIPMessage::~CIPMessage(void)" (??1CIPMessage@@$$FQAE@XZ) referenced in function "void __clrcall `dynamic atexit destructor for 'MyMessObj''(void)" (???__FMyMessObj@@YMXXZ@?A0x282c2107@@$$FYMXXZ)
It's getting late now so I need to call it a night , but I was going to try writing some simple code tomorrow that tests the winsock2 functionality in this case.
Thanks again for your help.
|
|
|
|
|
It's fine that the include problem is solved. Did you move all includes to stdfax.h? That is not the usual way but will be OK for small projects. Stdafx.h should only contain system includes like winsock2.h, not your project specific header files which should be included by the cpp files that need them.
The linker errors complain about the missing constructor and destructor of the CIPMessage class used as member or base class for the MyMessObjClass . To resolve this, you must add the source file with the implementation to your project (chat_client.cpp).
|
|
|
|
|
Excellent, it's all working I was missing a portion of the source code for CIPMessage and also needed to add "ws2_32.lib" to Linker -> Additional Dependancies (at least I figured one thing out for myself ).
Thank you very much for taking the time to help me with this and explain stdafx.h. Great stuff
|
|
|
|
|
Fine that all is working. You are always welcome.
Just one more note:
You may replace the include of winsock2.h by afxsock.h in stdafx.h. Then you did not have to add the library to your project. That is done by import statements in afxsock.h and atlsocket.h:
#pragma comment(lib, "wsock32.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "mswsock.lib")
When creating a new MFC project and selecting "Windows Sockets" on the "Extended Features" tab, this will be already present in stdafx.h.
|
|
|
|
|
I have an extension dll. when I am building the dll in release mode, and call from the client mfc application it's launching, but when I am bulding the dll in debug mode and loading from client mfc application it's not launching giving error
//////////////////////////////////////////
debug assertion failed.
program:
file: f:\dd\cvtools\vc7libs\ship\atlmfc\src\mfc\appcore.cpp
line: 451
For more information on how your program can cause assertion failure, see visual c++ documentation on asserts
(Please retry to debug the application)
//////////////////////////////////////////
Please help me why this error is coming I am trying to launch the dll like this
[code]
hinstLib = LoadLibrary(L"C:\\Users\\sujan.dasmahapatra\\Documents\\Projects\\Bhagavan_SurfaceRevolution\\View inside a Dialog\\package\\RevolutionDLL\\debug\\dlltest.dll");
[/code]
when there is 'release' instead of debug it's working fine. Please help.
|
|
|
|
|
sujandasmahapatra wrote: when there is 'release' instead of debug it's working fine
probably not. but debug assertions don't happen in release mode. they're there to tell programmers that something seriously wrong has happened.
your best bet is to duplicate the problem in a debugger then see why that assertion is happening. then fix the problem.
|
|
|
|
|
sujandasmahapatra wrote: file: f:\dd\cvtools\vc7libs\ship\atlmfc\src\mfc\appcore.cpp
line: 451
Debug your code (single step), go to that line number and see what's asserting.
Read this excellent essay: Surviving the release build[^]
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
"Break" execution when the assertion is hit, then look at what the assertion is telling you. You can see what has been asserted (example):
ASSERT( pWnd );
ASSERT( pWnd!=NULL );
Then you can look at the call stack and trace back to your code (instead of looking at the mfc portion that triggered the assertion). You probably forgot to initialize something or did something incorrectly within the framework.
|
|
|
|
|
file: f:\dd\cvtools\vc7libs\ship\atlmfc\src\mfc\appcore.cpp
line: 451
You can debug the code at specified location or post that code here.
|
|
|
|