Monday, May 18, 2009

If at first you don't succeed whine and cry until Dad's ears bleed...

You ever see those commercials on TV where the Dad is teaching his son or daughter how to ride a bike. It’s all smiles right. The Dad runs behind the kids bike and lets go. The kid sails gloriously down the sidewalk, the tall flag attached to the seat waving triumphantly in the air as the kid wobbles his way to bike riding glory…

Well that is total horse shit.

Saturday my wife and I taught my son how to ride his bike. It was nothing but crying, yelling, and cussing… on both sides.

He wanted to quit, ride his scooter, play on the playground, clean his room, do the dishes, wash the car, finish his homework… pretty much anything other than get back on the bike and try again.

But we held strong, refusing to let him quit. And after one of the most miserable hours in our families history… he was up and riding his bike around the park. And I am proud of my little buddy.

Of course we didn’t bring a camera…

Pulled off a double feature this weekend. Angels and Demons Saturday and Star Trek on Sunday night.

A&D was ok. Still think Tom is out of his wheel house on this character. Another scavenger hunt with an foreign hottie-with-a-naughty-body in tow. It was entertaining. The best part was all the shots of the Large Hadron Collider. Worst part was the disorienting shots of the Large Hadron Collider and when the camera spins really fast around character for a reaction shot. C+.

Star Trek was pretty good. I think we are going to see a few more flicks with this crew. Lots of laugh, decent action, good actors. I didn’t get the chills when I first saw the enterprise like I did with the first Star Trek movie. But this is a new crew in an [SPOILER REMOVED – GO SEE THE MOVIE] so I am excited to see where it goes. Who knew Uhura was that fricken hot in her younger days… damn. B.

Writing is moving along. I bought a motivational book at the recommendation of some good friends of mine. The Success Principles. With my daily schedule so tight most of the time writing falls to second or third on the list of shit I do at night. Need to work on moving it up to first.

Pitched a new idea to some friends this weekend. It’s a sci-fi action adventure with a dash of Independence Day mixed in with some Explorers that starts with a very obscure phenomenon that has been occurring throughout history that scientists have not nailed down yet that I attribute to a theory that’s way out there. Fun stuff. More later.

That is all.

-Jim

Monday, May 4, 2009

Where the hell did he come from?

Slow work day so I thought I would toss a post on the blog…

Saw X-Men Origins: Wolverine last night.

I liked it. Decent twists, great action. Films like these are really hard to pull off in my opinion and here’s why.

Everyone in the comic universe knows where Wolverine is headed through comics or the three X-Men flicks. This makes it hard to create a compelling story that tells us where he started and takes us up to the point in the first X-Men movie where he’s kicking the shit it out of people in a dive somewhere in Canada.

I think Jackman did a decent job holding the story. Plus he runs around a lot of the time shirtless, sometimes pantless, with his muscles glistening which should please the ladies. I thought Liev Schreiber was awesome as Sabertooth.

I suspect they would have been better served had they stayed truer to the Wolverine: Origins comic book series which I found compelling.

I give it a B-.

Writing is going well. On page 30 or so of the rewrite. Would love to get the script registered and passed out to a small circle of folks soon.

I think for my next story I am going to do a thinner outline. I found that while I was doing my rewrite some really good ideas started popping out on the page. While I still think I need at least a high level road map of where I am going I like the freedom of surprising myself on the page.

I highly recommend visiting Scriptshadow (See the blog link on the right side of the page) every weekday and reading the scripts he posts. It’s educational and for me at least it is a very good motivator to write.

That is all.

-Jim

Thursday, March 12, 2009

Adding Progress Bars to Blogger


For those of you wanting to add progress bars to your blogger page here is how to do it.

Go to your Blogger account.

Click on Layout -> Edit HTML.

Scroll down the HTML code of your template until you see something like…

/* Comments Format
--------------------------------------------------*/

Paste the following script just above this line.


/* ~~~~~~~~~~~~Progress Bars~~~~~~~~~~~~~~~~~~~
----------------------------------------------- */
.prog-border {
height: 16px;
width: 214px;
background: #fff;
border: 1px solid silver;
margin: 0
padding: 0;
}

.prog-bar {
height: 6px;
margin: 2px;
padding: 0;
background: #33775f;
}

.prog-bar_blu {
height: 14px;
margin: 1px;
padding: 1;
background: #A4AEC4;
}

.prog-bar_grn {
height: 14px;
margin: 1px;
padding: 1;
background: #A5D63E
}

.prog-bar_ora {
height: 14px;
margin: 1px;
padding: 0;
background: #FCBD42
}

.prog-text {
height: 10px;
margin: 0px;
padding: 0;
white-space: nowrap;
text-align: left;
text-indent: 4px;
font-size: 10px;
font: 75% Arial,Helvetica,Verdana,Sans-serif;
color: #000000;
}


 


Save the template.

Click on Page Elements.

Add a Gadget.

Select HTML/JavaScript.

Open the gadget and paste the following code in the content box.

<pre><code>
<div align="center">Sci-Fi Action</div>
<div class="prog-border">
<div style="width:90%;" class="prog-bar_grn">
<div class="prog-text">Editing</div>
</div>
</div>

<p> <p>

<div align="center">Comedy</div>
<div class="prog-border">
<div style="width:10%;" class="prog-bar_ora">
<div class="prog-text">Breaking Story</div>
</div>
</div></p></p>
</code></pre>


 


This will give you two progress bars. Obviously you can remove or add however many you want by duplicated the script.

To change the progress increase the “width:80%;” to whatever you need. Only go up to 99% as any more makes the progress bar look odd at the end.

To change colors just change the class=”prog-bar_grn” to one of the following…

class=“prog-bar” for standard.
class=“prog-bar_blu ” for blue.
class=“prog-bar_grn” for green.
class=“prog-bar_ora” for orange.

If you feel adventurous you can go back to editing the HTML and add new progress bars. Find the script progress bar script you added and put in a new progress bar with a new name;

.prog-bar_grat {
height: 14px;
margin: 1px;
padding: 0;
background: #F8FAF8;


 


That is all.

-Jim

Capturing Soft Keys Events in Windows Mobile 6

During the course of a work day I google coding questions or examples at least ten times. The software engineering community is strong and I’ve always gotten the answer or at the very least been lead in the right direction.

It’s not my job to know everything about coding. It’s my job to solve the problem so if I find a solution on the web then I use it.

I recently encountered an issue with capturing soft key events from a Windows Mobile device. I ran across several projects that either didn’t work or the solution was suspect. After a few days of reading and testing applications I created a tailored solution that works for me.

Since I was unable to find an accurate solution to my specific problem I am publishing the finished class. The majority of the code came from Paul Kimmel and this article at developer.com.

http://www.developer.com/net/vb/article.php/10926_2193301_3


His solution is for standard windows and has a few issues. I converted his class to work with Windows Mobile 6 and fixed the bugs and errors that were presented when running the code in the Compact Framework.

I want to give a little something back to the community which I rely on so heavily. Feel free to contact me with any questions by leaving a comment along with your contact information.

The best way to get the code is to copy from the first header down. Paste it in Word so it formats it then cut and paste the code into an empty class in your project.

That is all.

-Jim

---------------- CODE ----------------


'***********************************************************************
'* Class: cKeyBoardHook
'* Description:
'* Encapsulates the keyboard hook functions.
'***********************************************************************


Imports System.Runtime.InteropServices
Imports System.Reflection
Imports System.Drawing
Imports System.Threading


Public Class cKeyboardHook


' Passes on the key to be processed by the form.
Public Event ProcessKey(ByVal pKey As Keys)


#Region "P/Invoke Declarations"


<dllimport("coredll.dll", SetLastError:=True)> _
Private Shared Function UnhookWindowsHookEx(ByVal hHook As Integer) as Integer
End Function


<dllimport("coredll.dll")> _
Private Shared Function SetWindowsHookEx(ByVal idHook As Integer, _
ByVal lpfn As KeyboardHookDelegate, _
ByVal hmod As Integer, _
ByVal dwThreadId As Integer) As Integer
End Function


<dllimport("coredll.dll")> _
Private Shared Function GetAsyncKeyState(ByVal vKey As Integer) As Int16
End Function


<dllimport("coredll.dll")> _
Private Shared Function CallNextHookEx(ByVal hHook As Integer, _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByVal lParam As KBDLLHOOKSTRUCT) As Integer
End Function


<dllimport("coredll.dll")> _
Private Shared Function GetModuleHandle(ByVal moduleName As String) As Integer
End Function


#End Region


#Region "Structures/Constants"


' Keyboard structure
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scanCode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure


' Low-Level Keyboard Constants
Private Const HC_ACTION As Integer = 0
Private Const WM_KEYDOWN As Integer = &H100
Private Const WM_KEYUP As Integer = &H101
Private Const WM_SYSKEYDOWN As Integer = &H104
Private Const WM_SYSKEYUP As Integer = &H105


' Virtual Keys
Private Const VK_TAB As Integer = &H9
Private Const VK_CONTROL As Integer = &H11
Private Const VK_ESCAPE As Integer = &H1B
Private Const VK_DELETE As Integer = &H2E


Private Const VK_F1 As Integer = &H70
Private Const VK_F2 As Integer = &H71


Private Const VK_LWIN As Integer = &H5B
Private Const VK_RWIN As Integer = &H5C
Private Const VK_APPS As Integer = &H5D
Private Const VK_OEMC5 As Integer = &HC5


' Common mistake to make this value 13...
Private Const WH_KEYBOARD_LL As Integer = 20


#End Region


#Region "Variables"
Private KeyboardHandle As Integer
#End Region


#Region "Delegates"
Private Delegate Function KeyboardHookDelegate(ByVal Code As Integer, _
ByVal wParam As Integer, _
ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Private callBack As KeyboardHookDelegate
#End Region


#Region "Keyboard Hook Functions"


'********************************************************************************
'* Procedure: HookKeyboard
'* Description:
'* Hooks the keyboard.
'********************************************************************************
Public Function HookKeyboard() As Boolean
Dim iHwnd As Integer = 0


Try
'Assign a function for the callback.
callBack = New KeyboardHookDelegate(AddressOf KeyboardCallback)
'Create the hook, return the handle to the keyboard
KeyboardHandle = SetWindowsHookEx(WH_KEYBOARD_LL, _
callBack, _
GetModuleHandle(Nothing), 0)


'If the handle is zero we're in trouble.
If KeyboardHandle = 0 Then
DebugMessage("ERROR - hook unsuccessful.")
Return False
Else
'Double check the hook.
Return CheckHooked()
End If


Catch ex As Exception
MessageBox.Show(String.Format("cKeyBoardHook::HookKeyboard - {0}", ex.Message))
End Try


End Function


'********************************************************************************
'* Procedure: UnhookKeyboard
'* Description:
'* Unhooks the keyboard.
'********************************************************************************
Public Sub UnhookKeyboard()
If (Hooked()) Then
DebugMessage("Keyboard unhooked")
Call UnhookWindowsHookEx(KeyboardHandle)
End If
End Sub


'********************************************************************************
'* Procedure: CheckHooked
'* Description:
'* Checks to see if we have a hook to the keyboard.
'********************************************************************************
Public Function CheckHooked() As Boolean
If (Hooked()) Then
Return True
DebugMessage("Keyboard hooked")
Else
Return False
DebugMessage("Keyboard hook failed: " & Err.LastDllError)
End If
End Function


'********************************************************************************
'* Procedure: KeyboardCallback
'* Description:
'* Delegate function for the keyboard hook to call.
'********************************************************************************
Private Function KeyboardCallback(ByVal Code As Integer, _
ByVal wParam As Integer, _
ByRef lParam As KBDLLHOOKSTRUCT) As Integer


Try
If (Code = HC_ACTION) Then
'Define Key event otherwise it will fire for both KeyUp and KeyDown
If (wParam = WM_KEYUP Or wParam = WM_SYSKEYUP) Then
DebugMessage("Calling IsHooked")
'Pass the structure in.
If (IsHooked(lParam)) Then
'If we processed the key do NOT pass it on.
Return 0
Else
'Not a keystroke we care about so send it on.
Return CallNextHookEx(KeyboardHandle, Code, wParam, lParam)
End If


End If


End If


Catch ex As Exception
MessageBox.Show(String.Format("cKeyBoardHook::KeyboardCallback - {0}", _
ex.Message))
End Try


End Function


'********************************************************************************
'* Procedure: IsHooked
'* Description:
'* Implement this function to trap as many key combinations as you'd like.
'* Return true if you want to block the key, False to pass it on.
'********************************************************************************
Private Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean


Dim retVal As Boolean = False


Try
'Use GetAsyncKeyState to see if an additional key was pressed.
'I.E. Tab, Shift, Control etc.


'Example:
'If CInt(GetAsyncKeyState(VK_CONTROL)) <> 0 Then
' 'Control Key has been pressed.
'End If


'F1 & F2 are the predefined soft keys for the device.
Select Case Hookstruct.vkCode
Case VK_F1
DebugMessage("F1")
'Send the key on to the application.
RaiseEvent ProcessKey(Keys.F1)
retVal = True


Case VK_F2
DebugMessage("F2")
'Send the key on to the application.
RaiseEvent ProcessKey(Keys.F2)
retVal = True


Case VK_LWIN
'Block left windows key
DebugMessage("Left Windows Key")
retVal = True


Case VK_RWIN
'Block right windows key
DebugMessage("Right Windows Key")
retVal = True


Case VK_APPS
'Block Applications key
DebugMessage("Windows Application Key")
retVal = True


Case VK_OEMC5
'Blocking this key to prevent window launch
DebugMessage("OEM C5")
retVal = True


Case Else
DebugMessage(Hookstruct.vkCode.ToString())
retVal = False
End Select


Return retVal


Catch ex As Exception
MessageBox.Show(String.Format("cKeyBoardHook::IsHooked - {0}", ex.Message))
End Try


End Function


'********************************************************************************
'* Procedure: DebugMessage
'* Description:
'* Post the message to debug or a log.
'********************************************************************************
Private Sub DebugMessage(ByVal Text As String)
Debug.WriteLine(Text)
End Sub


'********************************************************************************
'* Procedure: Hooked
'* Description:
'* Are we hooked?
'********************************************************************************
Public Function Hooked() As Boolean
Hooked = KeyboardHandle <> 0
End Function


#End Region


End Class


Wednesday, February 11, 2009

Cookin

Second draft of my first screen is completed, printed out, and simmering on my desk. I am breaking the story of my next project for the next few days. Then it's back for a final edit before I send it out to folks for a read.

Stay tuned.

-Jim