I'm currently making a class wrapper in AutoHotkey for Scintilla (currently v5.0.1). I'm not sure what issue I'm having trying to make a text margin. It seems it should be incredibly simple. I'm just asking for help with order of operations using Scintilla (not for AHK help).
I'm trying to perform the following:
ctl := g.AddScintilla("vMyScintilla w500 h500")
m1 := ctl.Margin ; isolate Margin object from control (used internally)
m1.ID := 1 ; selecting margin ID (used internally by the class)
m1.Width := 100 ; setting margin width (SCI_SETMARGINWIDTHN)
m1.Type := 4 ; set margin type 4, text margin (SCI_SETMARGINTYPEN)
m1.Text(1,"asdf") ; SCI_MARGINSETTEXT (insert text to line 1)
msgbox m1.Text(1) ; try to get text from margin line 1 ... "asdf"
I see the margin extend itself to 100px as specified in the code (hard to miss). I left everything as 0-based, so margin 1 is the symbol margin after the number margin.
The msgbox at the end shows the text i put in the margin, so it appears to succeed, but the text is not displaying.
I have tried adding a style to the text with SCI_MARGINSETSTYLE, but it has had no effect. I've even changed my windows theme to make sure the text didn't happen to be the same color as the margin background, but that doesn't seem to be the case.
I get no errors from the AHK script.
I can't figure out what I'm missing. I've made it through over 50% of the Scintilla docs with no issues, but I'm stumped.
It was laughably simple.
I was testing on a single line document. And I set my "test line" to 1, instead of 0 (because it's 0-based).
Related
How can I custom specify, or force, the color of WS_EX_CLIENTEDGE [+E0x200]? I want a much more toned down color for it.
CustomColor := 000055
RequestToDisplay := "I want to change the color of WS_EX_CLIENTEDGE"
RequestTitle := "[REQUEST]"
GUI Request:FONT, s9 w1000 Q5, Verdana
GUI Request:COLOR, %CustomColor%, 000001
GUI Request:Add, EDIT, vMyAddress cFFFFFF r3 w400 xp-11 yp-0 -VScroll Multi WantTab t8 +E0x200 +Left
GUI Request:+LastFound +AlwaysOnTop -Caption -SysMenu
GUI Request:MARGIN, 0, 0
GUI Request:SHOW, x200 y300, %RequestTitle%
ControlSend, Edit1, %RequestToDisplay%, %RequestTitle%
return
ESC::ExitApp
or you might be looking for one of the parameter specified in https://msdn.microsoft.com/en-us/library/windows/desktop/ms724371(v=vs.85).aspx
for instance, see COLOR_ACTIVEBORDER
and for autohotkey SetSysColors dllcall see https://autohotkey.com/board/topic/36724-setsyscolors-set-system-colors/
hope this helps
steph
CP,
to my understanding, WS_EX_CLIENTEDGE is a window style (https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx).
to change the color of the edge that this window style produces, is an entire other question.
i would not know how to formulate this precise question.
but looking at your autohotkey code (AUTOHOTKEY changing WS_EX_CLIENTEDGE color), i see that CustomColor := 000055, to me it looks like an hexadecimal color value specified in a decimal way, that is without the 0x prefix (but that would be mandatory in C/C++)
SP.
in my C/C++ understanding one changes window's elements color calling SetSysColors() function see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724940(v=vs.85).aspx for an example.
in that example, COLOR_ACTIVECAPTION is used to specify the window border element's color, it might be the one you are looking for.
I have the problem that the text on three UIButtons gets wrapped to several lines in the Interface Builder, but when I run the code, the text is larger than the button and in one line only. I tried setting NSLineBreakMode and NSTextAlignment, but both didn't help.
In the Interface Builder it looks correctly like this: http://imgur.com/WplkqQV while on the simulator it looks like this: http://imgur.com/0YPpEfU. Any ideas?
Thanks in advance.
There is certainly something very odd about your example; I can't reproduce it. You must be doing something to the buttons that you have not described in the information provided by your question. If you set up your button line break mode to be Word Wrap (in the nib), and if your constraints are sensible so that the button can get wider in landscape and narrower in portrait, then it will wrap in portrait and not in landscape, which I believe is what you want. Here are screen shots of a button in the Simulator on my machine (ignore the actual widths of the buttons; it's only an example; what's important is the text wrapping):
The real problem, however, is the height. You'll notice that that isn't changing. This is because a round rect button has an intrinsic height value. If you want the height to change, to make more vertical room for the wrapped text, you will probably need to subclass or intervene in the layout process after rotation. For example, I get pretty nice results like this:
-(void)viewDidLayoutSubviews {
CGRect f = self.button.bounds;
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
f.size.height = 44;
else
f.size.height = 60;
self.button.bounds = f;
}
I'm using LaTeX and I would like to have vertical rule along left side of page, topmargin to bottommargin, 0.5in from the left edge of the page. I want this on every page, so I assume that means it must somehow be tied to the header or the footer?
I've made no progress at all, so I need help with (1) making the full-length rule itself and (2) making it happen automatically on every page of the document.
Can someone tell me how to do that?
I got a working answer to my question on the Latex Community forum: http://www.latex-community.org/forum/viewtopic.php?f=5&t=9072&p=34877#p34877
The answer I got uses the 'Background' package and this code:
\documentclass{article}
\usepackage{background}
\usepackage{lipsum}% just to generate filler text for the example
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgContents{\rule{.4pt}{\paperheight}}
\SetBgHshift{-9cm}
\begin{document}
\lipsum[1-90]
\end{document}
Works great and was easy to adjust to put one vrule in left margin area and one in the right margin area.
There could be a LaTeX package to do this for you, but I'm more of a TeX person, so I tried to come up with a TeX solution (not always the best idea to mix plain TeX with LaTeX but I think I have it working).
Try this. Box 255 is the box register that TeX places the page contents into before the page is output. What I've done is taken the existing output routine, and changed it to insert into box 255: a 0-height, 0-width infinitely shrinkable-but-overflowing set of boxes containing a rule that is the height of the page, 0.4pt thick and with any luck, half an inch away into the left. The existing contents of box 255 is then added after this rule. Then I call the previous output routine which outputs the page (which now includes a rule), and also the headers and footers.
\newtoks\oldoutput
\oldoutput=\expandafter{\the\output}%
\output{%
\setbox255\vbox to 0pt{%
\hbox to 0pt{%
\vsize\ht255%
\vbox to \ht255{%
\vss
\hbox to -0.5in{%
\hss
\vrule height \ht255 width 0.4pt%
}%
}\hss
}\vss
\box255%
}%
\the\oldoutput
}%
Put it before your \begin{document} command. This might not solve your problem completely, but hopefully it should get you started. Here's a great page for learning about TeX primitives and built-in things.
Have a look at the eso-pic package. From memory, what you want would look like this:
\AddToShipoutPicture{%
\setlength\unitlength{1in}%
\AtPageUpperLeft{%
\put(0.5,\topmargin){\vrule width .5pt height \textheight}%
}%
}
It's not clear in your question if you want the line to span the text area or the whole paper height. Depending on the case, you have to replace \topmargin and \textheight by the correct values, either 0pt or whatever your top margin is, or by \paperheight. See the geometry package if you don't already use it for how to control those dimensions.
I am trying to send data to a specific MergeField. The data are sent correctly. Each line of the data has for specific characters. For example the data to the field may be:
12345 FIRST\nABCDE.F SECOND
(it cannot get the newline so i just so it through character \n)
Now in the printed document each character has its one width, '1' is smaller than 'E' for example. So the data are not alligned within the field. I tried the following fonts: Arial, Tahoma, Courier New. Nothing helped.
Any ideas? Thanks in advance.
Ps the data are sent through an executable built by Visual C++ 5.0!!
You should probably use a tab-stop based layout. Set your tab-stops every, say, centimetre or so (i.e. just big than the widest character in your font) and add a tab before each element that needs to be aligned.
With this you shouldn't need to find a fixed width font and can use something more attractive.
Edit: Out of interest, I wonder why you have no luck with Courier New which is fixed width.
Maybe you could post a screenshot somewhere so we can have a look at your problem in more detail.
Try Courier - it does not have kerning (kerning = variable character width)
Also in the Font window there is a check box that allows you to apply kerning to fonts of a certain size or above - setting this value to a large font size may remove kerning.
How do you determine the length of a string of text in Arial Bold font, and then center it in VB6?
We are not using a "label" or "picture box" to print the text to the screen. We are sizing the text on the fly, and allowing the user to scale the size of our application to their liking. We write the text to screen using code.
One way is to have a hidden picture box and setup the font specs of that picture box the way you want.
Then use the TextHeight and TextWidth methods of the PictureBox to take your measurements. The Units will be in whatever scalemode the Picture Box is set to.
If you are printing directly to the printer or form then just set your font FIRST then take your measurements.
To center it
MyText = "Hello World"
<displayarea>.FontName = "Arial"
<displayarea>.FontSize = 14
<displayarea>.FontBold = True
TextWidth = <displayarea>.TextWidth(MyText)
TextLeftCoordinate = <displayarea>.ScaleLeft+<displayarea>.ScaleWidth/2-TextWidth/2
<displayarea>.CurrentX = TextLeftCoordinate
<displayarea>.Print MyText
Substitute displayarea with whatever object you are using.
Based on your updated answer note that the hidden picture box suggestion isn't used to print. It is only get text measurement. However you are printing directly to the form so you just need to use the code example above.
I can't remember the specifics (it's been about 3 years since I last used VB 6), but there's a method on Form called something like "MeasureString". It takes the string, and measures it according to the font settings of the form.
Also, here's a comment posted by Jason Lepack in case I've misunderstood and over-complicated your requirements:
"Labels usually have an alignment property. If you set it to align to center then, regardless of the font face it should center in the label".
There are Win32 GDI functions you can invoke: see for example GetTextExtentPoint32 at http://msdn.microsoft.com/en-us/library/ms534223(VS.85).aspx
Your best option may be Form.TextWidth, which appears to return the width of a string in twips. I've just taken this approach in order to dynamically size a button based on the length of the label that needs to appear inside it.
There is also a corresponding function called Form.TextHeight which would allow you to do the same thing in the vertical dimension.
Make sure that you set the Font property of the form to match the Font property of the control you're intending to measure the text for, otherwise you'll get incorrect results.
Read more at http://msdn.microsoft.com/en-us/library/aa267168(VS.60).aspx