I'm trying to use the windiff feature to compare two source code files. I'm not sure where this gets invoked though. If I just enter it in a Windows command window I get "windiff is not recognized as an internal or external command, operable program, or batch file". If I bring up a command window in Visual Studio via the View->Other Windows->Command Window menu option and then type windiff in there I get "Command windiff is not valid" If I run the MSDN Library program and try to find a command window there to invoke windiff, I can't seem to find any way to bring up a command window. What am I missing here? Robert
rmnowick
Posts
-
windiff usage -
Folder creation from inline code?Hi, Just wondering if anyone can point me to a C++ function or run-time library call that I can use to create a new folder like this: NewFolder("C:\\Engineering Data\\Diagnostic Data\\2004_10_15"); I did find SHFileOperations but that seems to be used for deleting, renaming or moving files. I just need to create a new folder under an already existing folder. The higher folder "Diagnostic Data" as used above will always exist if that matters. Thanks, Robert
-
Picture Control QuestionI'm working in Visual C++ (non-MFC). All the information in the help structure seems to show Visual Basic examples. Can you point me to a help topic that would show me how to do what you are suggesting? Yes, if I can call a routine that draws a rectangle of a certain size and color on my main display, that is all that I need to do. Robert
-
Picture Control QuestionAll, I am trying to use the Picture Control tool from the toolbox to add a picture to my main display window. The picture would be a small box located to the right of text string. When I create the picture control, there is an "Image" field whose description reads as follows: Image: When Type is Icon or Bitmap, specifies the identifier of the image to use So, I set the Type filed to either Icon or Bitmap. But, I am unable to enter a file location of the image that I would like to load. When I enter the string C:\Red Button.bmp into the Image field it comes back with the error: The identifier contains illegal characters The bigger picture here is that I have a list of voltages and temperatures being displayed numerically. Next to each one I would like to display either a green, yellow, or red small rectangle to indicate whether the engineering readings are ok or need some type of action. I thought I could just use the picture control to put up pictures of solid colored rectangles, and that the code might be able to change these on the fly somehow. Robert
-
SetDlgItemText from different thread ?Well, I have it working now but I'm still not sure exactly what is going on. This much I can say. The variable "hwnd" within DialogProc only exists when in the DialogProc routine. So, I created another variable called global_hdlg which I set to hdlg every time DialogProc is called. The other thread then declares global_hdlg as extern and passes it into SetDlgItemText. There must be a cleaner way to do this? Robert
-
SetDlgItemText from different thread ?I have some additional information. When running the code in debug I found that the value of hdlg in the code above was zero. That explains why the SetDlgItemText was not working. This presumably comes from my main dialog window code. The routine above has an extern HWND hdlg; so as to specify that the hdlg is declared in a different file. When looking through my dialog routine the interesting thing is that there does not appear to be anywhere that the variable hdlg gets set! Here is the code that creates the dialog box in question that doesn't return until the dialog box goes away...
return DialogBox(hInstance, // was (HINSTANCE)hInstance MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) DialogProc);
When you look into DialogProc you see the following...BOOL CALLBACK DialogProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { // Only save the first DBG_SIZE received serial message notifications if (t_win_msgs < DBG_SIZE) { GetTimeStampStr(ats, char_ts, char_ts2); strcpy(win_msg_time[t_win_msgs],char_ts2); win_msg[t_win_msgs] = uMsg; strcpy(win_msg_text[t_win_msgs],""); if (uMsg == WM_COMMAND) strcpy(win_msg_text[t_win_msgs],"WM_COMMAND"); if (uMsg == WM_TIMER) strcpy(win_msg_text[t_win_msgs],"WM_TIMER"); if (uMsg == WM_AGILENT) strcpy(win_msg_text[t_win_msgs],"ser agi"); win_hi_wp[t_win_msgs] = HIWORD(wParam); win_lo_wp[t_win_msgs] = LOWORD(wParam); t_win_msgs++; // Total messages } switch (uMsg) { case WM_AGILENT: return 1; case WM_INITDIALOG: //----------------------------INITDIALOG InitDialogProc(hdlg, uMsg, wParam, lParam); return 1; // Serial data processing if done periodically case WM_TIMER: SetDlgItemText(hdlg,IDC_STATIC_1,(LPCSTR)static_message_101); SetDlgItemText(hdlg,IDC_STATIC_2,(LPCSTR)static_message_106); return 1;
The hwnd variable is the first parameter passed into DialogProc. It is then passed as the first parameter to InitDialogProc. It is used in there to do a bunch of stuff including naming the window title, etc... But as I mentioned it does not appear to actually get set anywhere that I can see, unless it is somehow done automatically? If so, then why can't I see it in the other thread? The description of the DialogProc routine seems to show that the first parameter (hdlg) is passed in. In my code, this is not getting set prior to the call to DialogBox that has DialogProc as the 4th parameter. When I set a break in Di -
SetDlgItemText from different thread ?Hello, I have a dialog box that contains a static text field. The field is just empty and serves as a box that I want to write a number into later. When I use SetDlgItemText I can set the value of the static text field. If I try to call SetDlgItemText from a different thread then I can't seem to get it to work. Anyone ever encounter this problem? The thread I'm trying to call SetDlgItemText from was created by the thread that the dialog box is part of, so I guess it would be a child thread trying to update a static text box in the parents thread. Here is what the code looks like:
sprintf(static_message,"%8.3f",measured_value_float); if (chan_num_int == 101) { strcpy(static_message_101,static_message); //SetDlgItemText(hdlg,IDC_STATIC_1,static_message); } if (chan_num_int == 106) { strcpy(static_message_106,static_message); //SetDlgItemText(hdlg,IDC_STATIC_2,static_message); }
Right now I'm just moving the values into the variables that start with static_message_10N. The dialog then checks these global variables every second and calls SetDlgItemText itself. I would think that it would be much cleaner if I could just have the other thread do it. Thanks, Robert -
How can I monitor data on a serial port opened by another application?Jim, I don't know how to do this from Visual C++, but I believe that it can be done. A product that I purchased not too long ago does just that. It is called "Advanced Serial Port Monitor" and is available from here: http://www.aggsoft.com/products/supercom/ I believe they also offer a software development kit that might be just what you need. The product is great too. Robert
-
Combo box not showing pull down listMr. Prakash, Thanks, I found a similar answer in another thread, from another Indian guy :) In the resource editor if you click in the middle of the combo box, blue squares appear on the left and right, allowing you to make the box wider or narrower. But, if you click on the pulldown itself, there is a single blue box in the bottom center. Grabbing that blue box and pulling it down defines what size the combo box is when initially displayed. Too bad they don't say anything about this in the help area... Actually, it is explained. It is under "Combo Boxes" then "sizing". Robert
-
Combo box not showing pull down listAll, I have created a combo box from the same set of parameters used to create a previous combo box. I hace verified that they have the same properties. Here are the properties. All "False" except where noted: Data: empty box ID: IDC_TRIGGERING Owner Draw: No Tabstop: True Type: Drop List Vertical Scrollbar: True Visible: True The idea is that I wish to present the user with a fixed list of values to choose from. The code to add items to the list is as follows:
nTriggerMode = GetPrivateProfileInt("Settings", "Triggering Mode", 0, "sdkdemo.ini");
lResult = SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_ADDSTRING, 0, (long)"10");
lResult = SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_ADDSTRING, 0, (long)"15");
SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_ADDSTRING, 0, (long)"20");
SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_SETCURSEL, nTriggerMode, 0);The lResult variable is being incremented as the numbers are being added to the combo box, so that appears to be working. The value of nTriggerMode is pulled out of a file and whatever value it is set to initially (0, 1 or 2) successfully controls which of the three items is first shown in the display (10, 15 or 20). Life is good... Except, when I try and use the combo box by left clicking in the pulldown on the right of the box, nothing happens except that I get a narrow black line (1/16 inch) that appears under the combo box. The line then disappears when I click the pulldown again. The list of 3 items never appears. I don't believe that I need to process messages for the combo box. The other application didn't. When I want to know what value the user has most recently entered I just do the following:
nTriggerMode = SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_GETCURSEL, 0, 0);
Any ideas? Robert P.S. I am not using MFC in this code.
-
PostMessage question...Antony, Thanks for the tip. I switched the call to PostThreadMessage and in my thread I now periodically check for message arrival with PeekMessage and am seeing them there. Robert
-
PostMessage question...All, I posted this message on the following board, but since this area gets more traffic, and also since I don't believe the problem is necessarily related to the serial code, I will repost it here: http://www.codeproject.com/system/serial.asp?target=serial Ramon, I'm guessing that you might be the only one that might be able to answer this. I have had great success incorporating your sample code into my project. I am controlling an external device that I write to once a second to start it performing a series of A/D conversions. When it is done it sends the data back, and the reader thread notifies my dialog box that there is data via the PostMessage routine. So far so good. Because I had a need to send data to the external device every second, I created a second writer thread, similar to the reader thread. I essentially copied the code and changed names and such and I now bring up both threads. My main dialog window is still the destination for the messages that get sent by the PostMessage routine. Here is my problem. The application that I incorporated your code into has a hard coded loop in the main DialogProc routine. This is perhaps not good programming practice as it hangs the code from processing any windows messages, including the messages from PostMessage that indicate that there is serial data to be read. What happens is then that I miss the serial data. What I need to be able to do is run that main loop AND process the messages that indicate there is serial data coming in. I tried to solve this by creating a new window within the writer thread that has it's own doalog processor for windows messages. Here is that code:
wc.style = CS\_HREDRAW | CS\_VREDRAW; wc.lpfnWndProc = (WNDPROC) MyWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI\_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC\_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE\_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "MyWindowClass"; returned\_class\_atom = RegisterClass(&wc); if (!returned\_class\_atom) { last\_err = GetLastError(); } // Create window to handle the incoming serial data arrival notifications agilent\_receiver = CreateWindow("MyWindowClass", // Was "MyWindowClass" "Nothing", WS\_MAXIMIZE, CW\_USEDEFAULT, CW\_USEDEFAULT, CW\_USEDEFAULT, CW\_USEDEFAULT, HWND\_MESSAGE, NULL, NULL, lpvoid\_null); if (agilent\_receiver == NULL) { debug\_stop = 1; last\_err = GetLastError(); }
This code a
-
GetLastError problemThis was the problem. I had the following code commented out:
//wc.hbrBackground = GetStockObject(WHITE_BRUSH);
I believe I did this because it didn't compile. I had to add a cast to it:
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
The code was originally from some sample code. Figures it wouldn't compile...
// Register the main window class. wc.style = CS\_HREDRAW | CS\_VREDRAW; wc.lpfnWndProc = (WNDPROC) MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon(NULL, IDI\_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC\_ARROW); wc.hbrBackground = GetStockObject(WHITE\_BRUSH); wc.lpszMenuName = "MainMenu"; wc.lpszClassName = "MainWindowClass";
Thanks Maksim, Robert
-
GetLastError problemNeville, My hInstance param comes right from my main window creation, just like the example:
int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR szCmdLine, int nShow)
{hInstance = hInst;
I changed the name of my WindowProc routine to MyWindowProc just so that it wasn't the default anymore. That routine is at the top of the module that contains the code in question:
LRESULT CALLBACK MyWindowProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
int dummy_var;dummy\_var = 1; return 1;
}
My lpszMenuName is NULL. My intent is to create a window that is invisible later on by calling CreateWindow for the purpose of processing messages only. The reason that I am calling RegisterClass is because I assumed that I needed to do this prior to getting the CreateWindow to work. BTW, that is also returning a 0 when it fails and I check GetLastError. Very strange. The help message that describes the kind of window that I want to create is here: From CreateWindow...
hWndParent
[in] Handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. This parameter is optional for pop-up windows.
Windows 2000/XP: To create a message-only window, supply HWND_MESSAGE or a handle to an existing message-only window.Message-Only Windows
A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.To create a message-only window, specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx function. You can also change an existing window to a message-only window by specifying HWND_MESSAGE in the hWndNewParent parameter of the SetParent function.
To find message-only windows, specify HWND_MESSAGE in the hwndParent parameter of the FindWindowEx function. In addition, FindWindowEx searches message-only windows as well as top-level windows if both the hwndParent and hwndChildAfter parameters are NULL.
As to the last reference to MFC, I am not using it. Robert
-
GetLastError problemYes
-
GetLastError problemI have the following code that I am executing:
DWORD last_err;
WNDCLASS wc;wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
//wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = "MainMenu";
wc.lpszClassName = "MainWindowClass";if (!RegisterClass(&wc)) { last\_err = GetLastError(); }
The RegisterClass call fails and when I run the code in debug and last_err gets set it has a value of 0. I'm expecting it to have a value that designates just what the error was. I got this code fom the following example:
int APIENTRY WinMain(
HINSTANCE hinstance, // handle to current instance
HINSTANCE hinstPrev, // handle to previous instance
LPSTR lpCmdLine, // address of command-line string
int nCmdShow) // show-window type
{
WNDCLASS wc;// Register the main window class. wc.style = CS\_HREDRAW | CS\_VREDRAW; wc.lpfnWndProc = (WNDPROC) MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon(NULL, IDI\_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC\_ARROW); wc.hbrBackground = GetStockObject(WHITE\_BRUSH); wc.lpszMenuName = "MainMenu"; wc.lpszClassName = "MainWindowClass"; if (!RegisterClass(&wc)) return FALSE; // // Process other messages. //
}
This comes from the help index under "Using Window Procedures". Robert
-
Static example compilation problemAll, I'm having trouble building my software when I include the 6 mentioned modules used for static display controls. My message at the end describes the linker errors I'm now getting. http://www.codeproject.com/staticctrl/digistring.asp?df=100&forumid=321&app=50&select=760102&msg=760102 I thought that I would post this here as that other board specific to the example doesn't appear to get much traffic. Thanks, Robert
-
Data display questionHello, I have inherited a GUI application that I am required to modify. One of the modifications that I have already implemented consists of capturing a serial data stream, doing some processing on it, and then writing it out to a file. The serial data is captured in a separate reader thread that signals the main dialog window when serial data is ready to be processed. This all works fine. The serial data stream consists of many voltage and temperature measurements collected from an attached A/D converter box. I parse the A/D data and keep track of the latest temperature and voltage measurements for all 22 channels that we are sampling. I would like to modify the main GUI display to also show the latest values of some if not all of the 22 channels that we are monitoring. In the simplest implementation, I could have a list down one side of a form that shows: Variable 1: 22.876 Volts Variable 2: 76.988 Degrees . . . Variable 22: 23.988 Volts To the right of each of these text labels I would like to have a small "window" where I could write the most recent value received for each of the data channels, be it tempearture or voltage. This way, the operator could see all the current data value on a single screen. The problem is that I have been looking through the Toolbox and there doesn't appear to be any sort of "box" structure that could be used for this purpose. Maybe I'm just missing it. Could someone please point me in the right direction. Perhaps there is a sample project that someone has done that would allow for a new tool like this? A second question revolves around going one step further. Since I am collecting this data over time, it would be nice to show the user say the last 10 minutes of data for any given variable in a "graph window", for lack of a better term. Does anyone have any links to a "graph tool" that I could use that might enable me to display my collected data in a graphical format in addition to the text display I mentioned earlier? Thanks, Robert
-
fprintf allowed in main dialog?When I go into the debugger the first argument to fprintf *str is apparently null. But, I don't open the file until a button on the GUI is pressed. The file name is based on the time that the button is hit. After opening the file I call SetTimer to fire every second at which time I try to write to the file. So, I wouldn't think that I would be writing to the file until the global variable FileOut2 gets set...
-
fprintf allowed in main dialog?All, I'm trying to do basic file I/O within the main dialog routine, the routine that all the GUI window notifications (WM_TIMER, etc.) are sent to. Is this allowed? The reason I ask is because when I try running the code I get a "Debug Assertion Failure" that states: File: fprintf Line: 56 Expression: Str != NULL I'm pretty new to Visual C++ so it may be that I just can't do file I/O there... Robert