@@ -881,7 +881,7 @@ extern "system" {
881881> To show the window—that is, make the window visible —pass the window handle to the
882882> [ ShowWindow] ( https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow ) function
883883
884- Hey, look, the MSDN docs are using some of that extended typography we mentioned before.
884+ Hey, look, the MSDN docs are using some of that extended typography we mentioned before (those dashes) .
885885
886886Apparently we want our window creation to look something like this:
887887``` rust
@@ -905,6 +905,9 @@ fn main() {
905905 core :: ptr :: null_mut (),
906906 )
907907 };
908+ if hwnd . is_null () {
909+ panic! (" Failed to create a window." );
910+ }
908911}
909912```
910913
@@ -936,9 +939,9 @@ use core::ptr::{null, null_mut};
936939```
937940
938941For calling ` ShowWindow ` , we have a ` HWND ` already,
939- but the show parameter is apparently another one of those WinMain arguments.
942+ but the show parameter is apparently another one of those ` WinMain ` arguments.
940943Instead we'll just look at the list of what the [ ShowWindow] ( https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow )
941- docs say, and I guess we can pick ` SW_SHOW ` .
944+ docs say we can send , and I guess we can pick ` SW_SHOW ` .
942945
943946``` rust
944947const SW_SHOW : c_int = 5 ;
@@ -950,8 +953,17 @@ extern "system" {
950953}
951954```
952955
953- Okay, now we can at least make the window and the program will close.
954- We expect it to like, flicker on screen really fast and then disappear, or something.
956+ And we add a call to ` ShowWindow ` after we've made our window and checked for a successful creation.
957+ ``` rust
958+ let _previously_visible = unsafe { ShowWindow (hwnd , SW_SHOW ) };
959+ ```
960+
961+ Okay, if we run our program now we * expect* it to at least make the window,
962+ but then the window will close when we go off the end of the ` main ` function and the process ends.
963+ So, it'll probably flicker on screen really fast and then disappear, or something.
964+ Right?
965+
966+ Let's give it a try...
955967```
956968D:\dev\triangle-from-scratch>cargo run
957969 Compiling triangle-from-scratch v0.1.0 (D:\dev\triangle-from-scratch)
0 commit comments