It's currently by default 16 or 8 I think. I would like it to be 4. How would I change this? Would I have to subclass?
It's currently by default 16 or 8 I think. I would like it to be 4. How would I change this? Would I have to subclass?
1978 Silver Anniversary Corvette
Huh? What are you asking?
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
You know when you use an edit control and then you hit the TAB key, it goes 16 (or maybe 8) spaces to the right (or left if you use SHIFT). How do I make the 16 (or 8) to 4?
1978 Silver Anniversary Corvette
I understand now! However. I don't know if I can help! If you are using a multiline editbox, you can send it EM_SETTABSTOPS message and set up the tabbing however you like, I don't think it works with single line edit boxes though, (you could always try).
Another approach of course, is to trap the TAB key press and insert the number of spaces you want in your string, bit fiddly though.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Well, it is a multiline edit, so how would I use this message? Just send it this message? What value would the params be? Which param would hold the new tab value? Thanks!
1978 Silver Anniversary Corvette
From MSDN...
>>>
An application sends an EM_SETTABSTOPS message to set the tab stops in a multiline edit control. When text is copied to the control, any tab character in the text causes space to be generated up to the next tab stop.
This message is processed only by multiline edit controls.
EM_SETTABSTOPS
wParam = (WPARAM) cTabs; // number of tab stops
lParam = (LPARAM) (LPDWORD) lpdwTabs; // tab stop array
Parameters
cTabs
Value of wParam. Specifies the number of tab stops contained in the lpdwTabs parameter. If this parameter is zero, the lpdwTabs parameter is ignored and default tab stops are set at every 32 dialog template units. If this parameter is 1, tab stops are set at every n dialog template units, where n is the distance pointed to by the ldpwTabs parameter. If the cTabs parameter is greater than 1, lpdwTabs points to an array of tab stops.
lpdwTabs
Value of lParam. Pointer to an array of unsigned integers specifying the tab stops, in dialog template units. If the cTabs parameter is 1, lpdwTabs points to an unsigned integer containing the distance between all tab stops, in dialog template units.
Return Values
If all the tabs are set, the return value is TRUE; otherwise, it is FALSE.
Remarks
The EM_SETTABSTOPS message does not automatically redraw the edit control window. If the application is changing the tab stops for text already in the edit control, it should call the InvalidateRect function to redraw the edit control window.
The values specified by the lpdwTabs parameter are in dialog template units, which are the device-independent units used in dialog box templates. To convert measurements from dialog template units to screen units (pixels), use the MapDialogRect function.
<<<
... so if you wanted to set all the tabstops the same, I would try setting wParam to 1, and lParam to a pointer to an int with the required value in it. Use SendMessage() to send the message.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Can you give me a code example? I'm getting this runtime error and I think it has to do something with my pointer...
1978 Silver Anniversary Corvette
Sorry for the delay, I could say busy at work or something, but the simple truth is that the sun has been shining for the last few days after almost two months of miserable weather, so we've been doing a few things. Anyway, compile this and fiddle with the value of the TabSize variable.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Okay, thanks!
1978 Silver Anniversary Corvette
I studied the code, and tried to now correctly set the tabs in my program, but it still isn't working! Here's my code:
This is just the beginning of the WndProc. What am I doing wrong?Code:LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndMEdit; /* file varialbes */ OPENFILENAME fname; char filename[64]; /* THE filename */ static char fn[256]; /* path and filename */ char filefilter[] = "Text\0*.TXT\0Assembly\0*.ASM\0\0\0"; static FILE *fp; char filestring[256]; unsigned int dwTabs = 4; switch(message) /* handle the messages */ { case WM_CREATE: hwndMEdit = CreateWindowEx(0, "edit", NULL, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0, 0, 0, 0, hwnd, (HMENU) ID_MEDIT, hInst, NULL); SetEditFont(hwndMEdit, "Courier", 12, ANSI_CHARSET, FALSE, FALSE, FALSE, FALSE); SendMessage(hwndMEdit, EM_SETTABSTOPS, (WPARAM) 1, (LPARAM) &dwTabs); SetFocus(hwndMEdit); return 0;
1978 Silver Anniversary Corvette
I'll have a look at your code, (sun still shining...), but tell me, did the program I sent you work in your environment?
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Well, I didn't compile your code, I just looked at how you implemented the EM_SETTABSTOPS message and tried to mirror it, but that wasn't successful.
1978 Silver Anniversary Corvette
Here is a modified version of my program using CreateWindowEx(), as you are, (although you don't need to use the Ex() version - but whatever). Compile it, it works.
When I looked at your code something that struck me was that you are creating an edit box at 0,0 but was 0 pixels by 0 pixels wide. That has got to be a fault.
What exactly is the problem you have?
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Oh, about the 0, 0, 0, 0 I move and resize the Edit Control in the WM_SIZE message. Is that a bad idea? But, I need that so if the user resizes the main window.Originally posted by adrianxw
Here is a modified version of my program using CreateWindowEx(), as you are, (although you don't need to use the Ex() version - but whatever). Compile it, it works.
When I looked at your code something that struck me was that you are creating an edit box at 0,0 but was 0 pixels by 0 pixels wide. That has got to be a fault.
What exactly is the problem you have?
The problem is when I run the program and hit TAB, it just goes one space. Nothing else...
1978 Silver Anniversary Corvette
Have you compiled and run either of mine? I want to know if they work in your environment. If so, we know the problem is with your program, if not then we know it is environmental.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.